fix: code correctness, security, and simplicity improvements
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user