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 nil check 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 snoozed state by passing the is_snoozed parameter 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

  1. 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
  2. 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

  1. Enable the todos_snoozing feature flag: http://gdk.test:3000/rails/features/todos_snoozing / https://gdk.test:3443/rails/features/todos_snoozing.

  2. Navigate to the GraphQL Explorer: https://gdk.test:3443/-/graphql-explorer.

  3. Snooze some to-dos:

    mutation SnoozeTodo($id: TodoID!, $snoozeUntil: Time!) {
      todoSnooze(input: { id: $id, snoozeUntil: $snoozeUntil }) {
        todo {
          id
          snoozedUntil
        }
      }
    }
  4. Fetch the to-dos:

    query Todos {
      currentUser {
        todos(sort: CREATED_DESC) {
          nodes {
            id
            snoozedUntil
          }
        }
      }
    }

Related to #17712 (closed)

Edited by Paul Gascou-Vaillancourt

Merge request reports

Loading
Loading