Snooze to-dos > Backend tweaks
What does this MR do and why?
This tweaks the to-dos snoozing backend implementation in preparation for implementing the frontend bits:
- A
nilcheck made it impossible to re-snooze a to-do that had already been snoozed once before. This check has been removed as to-dos can be snoozed any number of times. - It is now possible to filter to-dos by their
snoozedstate by passing theis_snoozedparameter to the finder.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Queries
-
Querying snoozed to-dos (query plan, not particularly relevant as no to-dos are snoozed in production yet):
SELECT "todos".* FROM "todos" LEFT JOIN banned_users ON todos.author_id = banned_users.user_id WHERE "todos"."user_id" = 1 AND ("todos"."state" IN ('pending')) AND "banned_users"."user_id" IS NULL AND ("todos"."state" IN ('pending')) AND "todos"."snoozed_until" > '2024-12-13 13:06:13.378719' ORDER BY "todos"."id" DESC -
Querying pending/not-snoozed to-dos (query plan):
SELECT "todos".* FROM "todos" LEFT JOIN banned_users ON todos.author_id = banned_users.user_id WHERE "todos"."user_id" = 1 AND ("todos"."state" IN ('pending')) AND "banned_users"."user_id" IS NULL AND ("todos"."state" IN ('pending')) AND ("todos"."snoozed_until" <= '2024-12-13 13:19:57.057567' OR "todos"."snoozed_until" IS NULL) ORDER BY "todos"."id" DESC
How to set up and validate locally
-
Enable the
todos_snoozingfeature flag: http://gdk.test:3000/rails/features/todos_snoozing / https://gdk.test:3443/rails/features/todos_snoozing. -
Navigate to the GraphQL Explorer: https://gdk.test:3443/-/graphql-explorer.
-
Snooze some to-dos:
mutation SnoozeTodo($id: TodoID!, $snoozeUntil: Time!) { todoSnooze(input: { id: $id, snoozeUntil: $snoozeUntil }) { todo { id snoozedUntil } } } -
Fetch the to-dos:
query Todos { currentUser { todos(sort: CREATED_DESC) { nodes { id snoozedUntil } } } }
Related to #17712 (closed)