Modify batch kudos notification code to avoid the Redis KEYS command

Description

Currently, the batch kudos notification code calls the Redis KEYS command once for each author who received kudos in the past day:

(source)

However, the Redis docs discourage the use of KEYS in production code:

Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use KEYS in your regular application code.

(source)

The batch kudos notification code should be rewritten to avoid the use of KEYS.

Notes

The deploy for this may be a bit tricky. Ideally, all users should be notified about all kudos they receive, even those that were recorded by the old kudos notification code right before the new kudos notification code goes live. There are several different possible approaches to take, including the following:

  1. Deploy the new code, then run rake notifications:deliver_kudos one last time on an old copy of the code (like ). This would result in an extra kudos email.

  2. Split this issue over two deploys: one to add extra sets for bookkeeping purposes (that aren't immediately used, because the data added just before the deploy wouldn't be tracked properly), and one to get rid of the call to KEYS (deployed at least a day later).

  3. Write an After task, to be run immediately after deploy, to make sure that all of the information added prior to the deploy is updated to match the new code.

Testing Instructions

The instructions for how to test the change from the old kudos notification code to the new kudos notification code will depend on the approach taken. However, the instructions for testing the new code should be the same in all cases:

  1. Find (or create) a work by an account whose email you have access to.

  2. Leave a logged-in kudos on the work.

  3. Leave a logged-out kudos on the work.

  4. Wait until the kudos notification emails are sent.

  5. Make sure that the email includes both of the kudos that you left.

Assignee

Unassigned

Reporter

ticking instant

Roadmap

Misc

Priority

Medium

Affects versions

Fix versions

None

Components

BackEnd

Difficulty

Medium

Milestone

Internal 0.9
Configure