-
Notifications
You must be signed in to change notification settings - Fork 4
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
Sends email notifications for directory entries with publication date… #1642
Sends email notifications for directory entries with publication date… #1642
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
src/onegov/org/cronjobs.py
Outdated
directory).query().filter( | ||
now >= ExtendedDirectoryEntry.publication_start, | ||
now < ExtendedDirectoryEntry.publication_end, | ||
# ExtendedDirectoryEntry.published == True, |
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 got confused as ExtendedDirectoryEntry.published == True
did not pass the tests. Any idea why?
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 question, not sure.
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 think this is currently a bit too complicated, I would use the exact same logic as in reindex_published_models
and just send notifications for everything that was published in the last hour, rather than rely on additional metadata.
In fact you can just add another isinstance(obj, ExtendedDirectoryEntry)
check to the existing function and trigger the notification in that same loop in order to avoid a redundant query.
Since cronjobs always run at specific intervals there's no chance of triggering too many notifications (there is however a small chance of skipping one during an upgrade)
While storing whether or not the notification was sent seems more robust at first, it also introduces potential confusion for entries that have their publication dates set a second time for republishing and then not triggering a second notification.
So if we wanted to handle that case properly we would need to introduce additional logic elsewhere. It doesn't seem worth the hassle right now.
Small caveat to my suggestion: Since the existing loop also includes recently unpublished objects you will need to check |
I will work on the approach with no metadata |
If we wanted to address this I think my preference would be to store on So here: onegov-cloud/src/onegov/org/cronjobs.py Lines 113 to 114 in f67e97d
Instead of now = utcnow()
then = request.app.org.meta.get('hourly_maintenance_tasks_last_run', now - timedelta(hours=1)) and at the end of the function you do request.app.org.meta['hourly_maintenance_tasks_last_run'] = now This also avoids potentially dropping anything in the small potential second gaps between cronjob runs due to jitter. |
I got it integrated |
Directory: Delay sending update notifications to subscribers if publication starts in future
TYPE: Feature
LINK: ogc-1825
Checklist