BinaryStudioAcademy / bsa-2024-gitfit

Application for collecting and analyzing developers activity on git based projects.
https://git-fit.net/
0 stars 0 forks source link

feat: Add notification for failed project activity update #336

Open liza-veis opened 4 days ago

liza-veis commented 4 days ago

What feature?

Screenshots

Screenshot 2024-09-16 at 17 34 17

AnnaRomaniuta commented 4 days ago

User Story: As a user, I want to receive notifications when project statistics are not updated for a certain period of time, so I can stay informed about project activity and take necessary actions.

Acceptance Criteria:

  1. A notifications icon is displayed in the header, accessible from any page.
  2. The relative time when the notification was received (3 days, 7 days, after that, send a notification every 7 days).
  3. Notifications are only sent for projects with a valid last activity date.
s1rserg commented 3 days ago

@liza-veis, I need to clarify a few moments about backend.

  1. So I need to create a notifications module and a notifications table for that. Should I omit status and type columns for now?
  2. Notification table has receiver_user_id column. Does it mean that only one user should receive the notification about failed project activity update? It just seems odd that notifications explicitly connected to users and not to project groups.
  3. Since analytics is updated every 3 hours should the notification cron job check for all project updates also every 3 hours and then compare last_activity_date to 3 days, 7 days and so on?
liza-veis commented 3 days ago
  1. So I need to create a notifications module and a notifications table for that. Should I omit status and type columns for now?

yes, let's omit unnecessary columns for now.

  1. Notification table has receiver_user_id column. Does it mean that only one user should receive the notification about failed project activity update? It just seems odd that notifications explicitly connected to users and not to project groups.

Notifications should be connected to users. We need to find all users that have access to the analytics: View All Projects, Manage All Projects (root permissions) or View Project, Edit Project, Manage Project (permissions for this project) and create notification for each of them (there should be an option for bulk creation).

  1. Since analytics is updated every 3 hours should the notification cron job check for all project updates also every 3 hours and then compare last_activity_date to 3 days, 7 days and so on?

No, no need for this logic, because we won't delete notifications, once they are sent.

s1rserg commented 3 days ago

No, no need for this logic, because we won't delete notifications, once they are sent.

Now i don't really understand how it should work. So the notification cron job should be global for all projects but run once a day or it should run separately for each project?

liza-veis commented 3 days ago

Now i don't really understand how it should work. So the notification cron job should be global for all projects but run once a day or it should run separately for each project?

I see the logic like this: We run one cron job every day, and inside it, we fetch all projects where the last activity log is less than the current date by our first threshold. Filter projects where needed number of days passed (either 3, or the number is dividable by 7), then for each of this project we need to find all eligible users and create the same notification for each of those users. And when we will fetch notifications for specific user, we will fetch them by user id