Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord Notification Dispatched on Nightly Cron (Rank Change) #1688

Open
FatihKoz opened this issue Nov 26, 2023 · 9 comments
Open

Discord Notification Dispatched on Nightly Cron (Rank Change) #1688

FatihKoz opened this issue Nov 26, 2023 · 9 comments

Comments

@FatihKoz
Copy link
Contributor

FatihKoz commented Nov 26, 2023

Discord Notification about Rank Changes is dispatched every night during cron checks even without changes to pilot ranks.

Version
7.0.0-dev+231122.a0ed24 (latest dev as of this report creation)

To Reproduce
No need to re-produce, either wait for nightly cron to run or trigger it manually

Expected behavior
If there is no change (due to stats calculation or corrections), notification should NOT be dispatched each night with same ranks over and over.

Screenshots
image

@arthurpar06
Copy link
Contributor

I think this issue and the previous one are related.
The Notification is dispatched when the UserStatsChanged event is dispatched https://github.com/nabeelio/phpvms/blob/dev/app/Notifications/NotificationEventsHandler.php#L289-L297.

But this event isn't dispatched only when a rank changes.
For example here the event is dispatched when a pirep is filed and the user has changed of location
https://github.com/nabeelio/phpvms/blob/dev/app/Services/PirepService.php#L727

I think adding a check in the onUserStatsChanged method like $event->stat_name == 'rank' should be a good solution for both issues.

@FatihKoz
Copy link
Contributor Author

Probably yes, I just did not had time to check how this is implemented. At first it was just dispatching the same rank over and over on each pirep, I fixed it but looks like this still needs some more changes/updates.

@arthurpar06
Copy link
Contributor

I think #1704 closes this issue

@FatihKoz
Copy link
Contributor Author

Strangely enough, it does not solve the issue fully... Pirep part is ok, it is solved but I am still getting them with nightly cron (all new members, no pireps, VA being built up, everyone is -new pilot-)

@arthurpar06
Copy link
Contributor

I can't reproduce it so it's complicated to debug it but it definitely comes from here (the only place where the event is fired during nightly cron). We should try to debug the differences between $original_rank_id and $user->rank_id and understand why they are not the same

@FatihKoz
Copy link
Contributor Author

FatihKoz commented Dec 10, 2023 via email

@arthurpar06
Copy link
Contributor

I was unable to reproduce it locally even after removing all pireps and setting all users to 0 flights. Do you still have this bug on your freshly installed va?

@FatihKoz
Copy link
Contributor Author

FatihKoz commented Dec 26, 2023 via email

@arthurpar06
Copy link
Contributor

arthurpar06 commented Dec 26, 2023

I really can't reproduce it...
If you want to try to debug from your install I think that the notification is sent just after this if is passed, this is where it would be interesting to debug $user->rank_id and $original_rank_id https://github.com/nabeelio/phpvms/blob/dev/app/Services/UserService.php#L500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants