There is an event table with the following structure: user_id id created_at (timestamp)
We need a request that pulls out all the entries added more than 30 minutes ago, gets user_id and pulls out all entries with this user_id in the last 30 minutes.
The task initially is this: you need to create a notification system. Accordingly, you need to send notifications in batches (several pieces), from one user "pack" should come no more than once every 30 minutes.
The user makes some edits in his profile, and then all these edits are grouped and sent to the admin (once every 30 minutes), in order not to clutter the edits for each user are grouped and sent in batches.
for example
| id | user_id | ------ | created_at
-1 ---- 5 ---------- a minute ago
-2 ---- 5 ---------- 5 minutes ago
For such a table, we do not pull anything out and for:
| id | user_id | ------ | created_at
-1 ---- 5 ---------- 31 minutes ago
-2 ---- 5 ---------- 5 minutes ago
We pull out all 2 records