janhebnes / startlist.club

Flight Log for flight clubs - created for handling flight log operations for soaring flight clubs in northern Europe.
https://startlist.club/about
MIT License
13 stars 10 forks source link

Fix for stale Flight object when returning from TrainingLog (Grading) #170

Closed plaursen closed 3 years ago

plaursen commented 3 years ago

When going back from TrainingLog, force the referrer (currently: Grid or flight Edit ) to reload, but (for flight Edit) in a way that preserves its referrer. Just calling location.reload() sets referrer to itself, which we don't want.

Problemet var, at det nye HasTrainingData felt blev overskrevet, hvis man gik via redigering af en flyvning, og trykkede Gem (selv om en Tilbage var nok). Det Flight object som var på Edit siden var forældet.

Det var lidt tricky, da man både skal fremtvinge en reload af der hvor man kom fra, og samtidig undgå at ødelægge Edit's UrlReferrer.

vi skal iøvrigt have kørt en stump SQL på Azure for at få det felt opdateret for gamle flyvninger:

update Flights set HasExercise=true where FlightId in (select distinct FlightId from [dbo].[AppliedExercises] where [Grading_GradingId] != 5)

og i princippet også

delete from [dbo].[AppliedExercises] where [Grading_GradingId] = 5

plaursen commented 3 years ago

Kører p.t. på dev