fix: code correctness, security, and simplicity improvements

This commit is contained in:
2026-08-13 21:23:15 +03:00
parent ac6efb45d8
commit e063d26d4c
5 changed files with 78 additions and 40 deletions

View File

@@ -66,9 +66,11 @@ func checkStationSchedule(ctx context.Context, yc *yandex.Client, stationID stri
}
// updateStationStatus updates the station's status in cache based on trip count.
// It returns the new status.
// It returns the new status. Writes status and zero-days count separately;
// partial failures may leave cache inconsistent but do not lose the core state.
func (sm *StationMonitor) updateStationStatus(ctx context.Context, tripCount int) (Status, error) {
cacheKey := stationStatusKey(sm.ID)
zeroDaysKey := zeroDaysKey(sm.ID)
// Get current status from cache
data, err := sm.Cache.Get(ctx, cacheKey)
@@ -87,7 +89,6 @@ func (sm *StationMonitor) updateStationStatus(ctx context.Context, tripCount int
}
// Get current zero-trip day count
zeroDaysKey := zeroDaysKey(sm.ID)
zeroDaysData, err := sm.Cache.Get(ctx, zeroDaysKey)
var zeroDays int
if err != nil {