Unschedule scheduled event status update only if last update was successful (#168)

This PR fixes an issue that prevented scheduled event status updates
from running again if they failed. This happened because, before each
update, the events would be synchronized. The `ScheduleOnStatusUpdated`
field would be set even if it's already `true`, which will cause it to
be set to `false` for unsuccessful updates. The issue is fixed by
surrounding the field set call with a condition that will prevent
setting the field from `true` to `false`
This commit is contained in:
Octol1ttle 2023-10-17 17:25:15 +05:00 committed by GitHub
parent 580cd24810
commit fead92129d
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,7 +114,11 @@ public sealed class ScheduledEventUpdateService : BackgroundService
var eventData = data.ScheduledEvents[@event.ID.Value]; var eventData = data.ScheduledEvents[@event.ID.Value];
eventData.Name = @event.Name; eventData.Name = @event.Name;
eventData.ScheduledStartTime = @event.ScheduledStartTime; eventData.ScheduledStartTime = @event.ScheduledStartTime;
eventData.ScheduleOnStatusUpdated = eventData.Status != @event.Status; if (!eventData.ScheduleOnStatusUpdated)
{
eventData.ScheduleOnStatusUpdated = eventData.Status != @event.Status;
}
eventData.Status = @event.Status; eventData.Status = @event.Status;
} }
} }