-
Notifications
You must be signed in to change notification settings - Fork 12
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
Calculate job percent complete only when the job has rows in the notification table #1664
Draft
whabanks
wants to merge
4
commits into
main
Choose a base branch
from
fix/div-by-zero-scheduled-jobs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−2
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
683cd57
Check if the job is currently scheduled before calculating percentage…
whabanks cd35e0f
Check notification count rather than if job is scheduled
whabanks 31b2a6e
Test that percentage_complete is not calc'd for scheduled jobs
whabanks 8b55902
Merge branch 'main' into fix/div-by-zero-scheduled-jobs
whabanks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if a job is still in a scheduled state then the
job["notification_count"]
is zero? I would have thought that would be the (eventual) total # of notifications?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree that the eventual # of notifications should be displayed on this page, but it looks like the job stats come from here in API and at a glance they don't seem to include scheduled notifications. I think that change might be a separate PR for a related bug (i.e. that scheduled notifications aren't part of the stats)
In terms of a guard against this page crashing, this change seems to fit the bill - I'm not sure we could do much more on the admin side if we're given a 0 for the
notification_count
. Although maybe the check should be ifjob["notification_count"]
is0
rather than if the job is scheduled?Out of scope for this PR, but for consistency sake, do scheduled notifications similarly count against the daily limit I wonder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point regarding the bug where scheduled notifications aren't part of the stats. When I tested locally and in staging the notifications for scheduled jobs only get created once the
scheduled_for
time has elapsed. So until the send occurs it seems we won't be able to include those notifications in the stats. It looks like this is the expected behaviour - I came across a test that indicates no stats should be returned if a job has no associated rows in the notifications table.That said, checking the
notification_count
instead of if the job isscheduled
makes more sense as eventually there will be notifications available in the DB for thepercent complete
calculation. I appreciate the discussion it's sparked a few ideas to flesh out unit tests in this area of the code! ❤️To answer your question about scheduled notifications counting against the daily limit, I think the answer is
yes
. When we create a job we increment the daily count in Redis.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking in the
jobs
table for a job I just created on staging and scheduled for 48 hours in the future:notification_count
is the number of notifications that will be eventually sent. @whabanks if you are able to schedule a job and you see anotification_count
of 0 that would be a bug. I think we still need to figure out how to reproduce that before we make any code changes.