fix: brief timing double-send + DB deadlocks; add minute/day scheduling#16
Merged
Merged
Conversation
Brief send-time was unreliable and could fire at two times a day. Root causes: - The popup auto re-link on every open sent brief_hour (defaulting to 8), silently overwriting a custom hour in the DB. - schedule_brief used reschedule_job against the persistent jobstore, so a stale trigger left by an overlapping scheduler could survive alongside the new one — firing the brief at both the old and new time. Fixes: - Stop the clobber: brief send-time fields are optional in /link-ontrack and preserved from the DB when absent; the auto re-link no longer sends them. - Make scheduling idempotent (remove-then-add → exactly one job per user) and reconcile orphan brief_* jobs on startup. Feature — fully customizable send time: - New brief_minute + brief_dow columns (migrated on both PG and SQLite). - Settings UI: native HH:MM time picker + Mon-Sun day checkboxes. - schedule_brief honours hour, minute and day_of_week. Deadlock fix: - The contended user row was updated by several separate transactions per request under concurrent extension traffic. Fold the Settings-panel writes into a single update_brief_prefs UPDATE, and add a retry-on-deadlock wrapper (Postgres 40P01/40001, SQLite "database is locked") on the write helpers.
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.
Brief send-time was unreliable and could fire at two times a day.
Root causes:
Fixes:
Feature — fully customizable send time:
Deadlock fix:
Summary
Related issue
Type of change
Checklist
mainruff check .passespytestpasses (if backend changes)npm run lintpasses inextension/(if extension changes).envfiles, tokens, or database filesNotes for reviewers