1
I want to make a system of notifications that come together when they’re the same type, like the ones on Facebook. For now I have the table with the following columns:
user_id (person receiving the notification),
icon (Usually another user’s profile photo),
Description (the description of the notification),
Registry (registration date),
Seen (a boolean who checks if the person has already viewed)
How I create notifications? Well, it happens when the action is executed. For example, I click the follow button So-and-so, within the function I record the notification, so:
user_id: User id I followed,
icon: My profile picture,
Description: Insanity started following you!,
Registry: CURRENT_TIME(),
Seen: 0
I have two main problems:
- If I keep clicking the follow button several times, it will send multiple notifications.
- The cluster problem: If more than one person follows, let’s assume that 1000 people do this, 1000 notifications will appear. How to group like Facebook, example: "Geraldo, Thiago and more 998 people started following you!".
I think the logic of face book is if you have more than x notifications it instead of displaying all it will display the last and how many other notifications you have of the same type
– Jasar Orion
This is kind of complex. But you will need to change the db structure: create a table with the activity types and then relate them to your current table (instead of the Description field). This will help the server to compare records: it is much faster to check two ints than two strings. (see about database normalization)
– rodorgas