Repository navigation
fix(events): record who created each event, and delete accounts without a foreign-key error - #564
Merged
Merged
Conversation
…gramme's order A record's coming assignments, and the last one done, read several of one meeting in whatever order the table returned them, so the record — and the reference suite — could change from one run to the next. They now follow the programme: parts, then services, each in their order.
Event.origin (job, manual, import; CHECK, default manual). Events without an author and with nothing on them — the empty meetings the recurring-events job created — become the job's.
…missing author Only the job's empty meetings move with their template or go with it. They were told apart by having no author, but clearing an author — deleting an account — would have turned a hand-made event into one. The job writes « job »; preparing a job meeting's programme or moving it by hand makes it « manual »; every check reads the origin.
…ated Deleting an account ended in a foreign-key error on any event it had created. An account without a record now takes its absences with it, and its other events lose their author and keep their origin, so a hand-made one stays where it is. An account linked to a record that has absences is refused: « Ce compte a des absences », until they can be handed to the record.
events.ndjson gains origin. A 2.18 archive's origin is kept; an older archive's event without an author and with nothing on it comes back as the job's, by the migration's rule, so it still moves with its template, and any other as « import » — as does an origin this version does not know.
Changed on purpose: event rows read whole gain `origin` — « job » on the eleven meetings created ahead, « manual » on the others, the same after a restore. Nothing else moved: the other changed lines are the commas before it.
« Créer le programme » named the person when an event had no author, the series did not: a hand-made meeting whose author's account was deleted got its programme with nobody named. Both now name whoever fills it, and leave a hand-made meeting's name and hours. Comments that tied a missing author to the job now say what the origin decides.
…he events it created « Retirer la connexion » deletes the login too, and still ended in the foreign-key error Réglages no longer has. Both now let go of the account's events through one helper: a record's absences refuse it, with their own message rather than the last administrator's; its other events lose their author. The audit trail keeps which absences went with a record-less account and how many events lost their author. A test deletes accounts, then changes and deletes their template: their hand-made meetings stay.
…d leave a restored event's origin A series passing a day deleted the meeting there on what it had read; the delete now checks it is still the job's empty meeting. « Créer le programme » turned a restored event without an author into « manual », the series did not: both now only change a job meeting's origin, and name whoever prepares an event without an author.
… and replay the step in the round trips The old-archive rule is checked on a service and on counts as well as a part, in runImport's order, and the two tests that replay runImport's sequence run the new step. The reference fixture names the meetings created ahead by their origin.
The author no longer stands for « made by the job »: the schema says who it names, and when it is null. The migration no longer promises a plain re-run of its backfill — a catch-up must keep to the rollout window. Origin docs say which actions make a meeting « manual » and what « import » covers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 0d of the event schedules plan (#533):
Event.origin(T10), and account deletion no longer failing.Why
An empty meeting the recurring-events job created ahead was recognised by having no author. Only those move with their template when its day changes, or go with it when it is deleted. But deleting an account must clear the author of what it created, and then a hand-made event would have looked exactly like one of the job's. So deleting an account could not be fixed until "made by the job" was recorded on its own.
What changes
Event.origin:job,manualorimport. It has a CHECK constraint and defaults tomanual. The migration givesjobto events without an author and with nothing on them (no part, service or counts), which is exactly what an empty meeting was until now.EMPTY_MEETINGand the three inline copies of the rule (time-zone re-anchoring, the import clean-up, the template page count), plus the series' empty-meeting test.job.manual.jobmeeting changes origin.Event.createdById, the only restricting key toUserAccount. This covers both paths that delete an account: Réglages › Utilisateurs, and « Retirer la connexion » on a publisher record. Both go through one helper,releaseAccountEvents.events.ndjsoncarriesorigin. A 2.18 archive's origin is kept. In an older archive, an event without an author and with nothing on it comes back asjobby the migration's rule, so it still moves with its template; any other event comes back asimport. An origin this version doesn't know also comes back asimport, with a warning.Also in this PR, as its own commit: a publisher record's assignments within one meeting (the coming ones and the last one done) now follow the programme's order. They came back in random order, which made
personal-views.referencefail at random in full runs.Rollout
While the new version deploys, the previous one keeps creating empty meetings at the default
manual. Those stop moving with their template until a later migration gives themjob. That migration must be limited to events created during the rollout: running this one's backfill again as it is would also flip a hand-made event whose author's account was deleted in the meantime. The migration header says so.References changed on purpose
Event rows read whole gain
origin:jobon the eleven meetings created ahead,manualon the others, and the same values after a restore. Nothing else moved; the other changed lines are the commas before it.Verification
job(a part, a service, counts or an author each keepmanual); idempotent; an unknown origin is refused.manual. With the switch removed, the test fails.runImport's order. Also an unknown origin. The two tests that replayrunImportrun the new step too.