Reset notification email to default when used email got deleted
What does this MR do and why?
Reset notification email to default when used email got deleted.
Fixes #438600.
How to set up and validate locally
- Add a secondary email in http://gdk.test:3000/-/profile/emails.
- Use http://gdk.test:3000/rails/letter_opener/ to see and click the confirmation link.
- Now go to http://gdk.test:3000/-/profile/notifications and use that new email for any group.
- Trigger a notification to see that it's working. Tip: Enable Receive notifications about your own activity on the same page.
- Check LetterOpener again and confirm the new email is used.
- Now delete this Email again (in http://gdk.test:3000/-/profile/emails).
- Trigger another notification, and confirm that the primary email got used, not the deleted one.
- Also check that your earlier changes in http://gdk.test:3000/-/profile/notifications got reset.
database query plan
- The
where().each_batch()
call results inSELECT
queries like these:
SELECT
"notification_settings"."id"
FROM
"notification_settings"
WHERE
"notification_settings"."user_id" = 1
AND "notification_settings"."notification_email" = 'aaa@bbb.ccc'
ORDER BY
"notification_settings"."id" ASC
LIMIT 1
SELECT
"notification_settings"."id"
FROM
"notification_settings"
WHERE
"notification_settings"."user_id" = 1
AND "notification_settings"."notification_email" = 'aaa@bbb.ccc'
AND "notification_settings"."id" >= 1
ORDER BY
"notification_settings"."id" ASC
LIMIT 1 OFFSET 500
- And the
update_all
then updates each batch in bulk
UPDATE
"notification_settings"
SET
"notification_email" = NULL
WHERE
"notification_settings"."user_id" = 1
AND "notification_settings"."notification_email" = 'aaa@bbb.ccc'
AND "notification_settings"."id" >= 1
All 3 query plans recommend adding a specialised index (email+user), which is part of this MR now.
Edited by Thomas Hutterer