Visitar URL original
Project cleanup deletes never-saved drafts by creation date, so a draft being edited right now can be removed · Issue #2677 · exelearning/exelearning · GitHub
Skip to content

Project cleanup deletes never-saved drafts by creation date, so a draft being edited right now can be removed #2677

Open

Description

@erseco

What happens

findUnsavedProjectsOlderThan (src/db/queries/projects.ts:770) selects never-saved drafts by created_at:

.where('saved_once', '=', 0)
.where('created_at', '<', cutoffTime)

So the retention window runs from the moment the draft was created, not from the last time it was touched. A draft that is being edited right now is deleted as soon as it is old enough, together with its assets, its yjs_updates and its version history. Nothing excludes a project with a live WebSocket room.

With the default 24 h: a teacher starts a project on Monday morning, works on it all day without ever pressing Save, and on Tuesday morning the sweep deletes it mid-session.

The sibling query for guest projects, findGuestProjectsOlderThan (:811), already uses updated_at — so the two halves of the same cleanup disagree about what "older than" means.

Why it matters now

The behaviour is pre-existing, but two recent changes raise its reach:

#2673 only corrects the wording — the help text now says drafts are deleted so many hours after they were created, even if they are still being edited — because changing which column is filtered is a behaviour change for an existing feature and deserves its own decision.

Options

  1. Filter on updated_at, matching the guest query. Simple, strictly less destructive, and matches what most people read into "delete abandoned drafts". Projects that are genuinely abandoned still go; the ones being worked on do not.
  2. Keep created_at and exclude projects with an open editing session (a live Yjs room, or a recent yjs_updates row). More faithful to "a draft should not live forever", more moving parts.
  3. Keep it as it is and rely on the corrected wording.

My preference is 1: it removes a data-loss edge with one word, and it makes the two finders consistent. If a hard ceiling on draft lifetime is wanted, that is better expressed as a separate, much longer limit than as a side effect of this one.

Done when

  • The chosen semantics are implemented in findUnsavedProjectsOlderThan, with a unit test in src/db/queries/projects.spec.ts covering a draft whose created_at is past the cutoff but whose updated_at is recent.
  • The cleanup_unsaved_desc help string in src/routes/admin.ts matches whatever is implemented.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions