Add configurable lookback window to the Handle Notifications job (#170) - #392
Open
jvanderaa wants to merge 2 commits into
Open
Add configurable lookback window to the Handle Notifications job (#170)#392jvanderaa wants to merge 2 commits into
jvanderaa wants to merge 2 commits into
Conversation
Adds two optional job inputs, 'Days to look back' (IntegerVar) and 'Fetch notifications since' (StringVar, ISO 8601), that override the normal incremental fetch window so operators can re-fetch older notifications on demand. When both are set the earliest start time wins. Nautobot has no DateTimeVar, so the datetime input is a validated string parsed with dateutil. Documents the feature and the delete-then-reprocess workflow for already-stored notifications. Closes #170
Collect override candidates as datetimes and convert to a timestamp once via min(), removing the duplicated int(...timestamp()) calls. Raise a clear error on an unparseable 'Fetch notifications since' value instead of returning an empty result, so the Job Result reflects the failure.
jvanderaa
requested review from
glennmatthews,
pke11y and
scetron
as code owners
July 20, 2026 23:01
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
glennmatthews
approved these changes
Aug 5, 2026
glennmatthews
left a comment
Contributor
There was a problem hiding this comment.
Looks reasonable to me.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes: #170
What's Changed
Adds two optional inputs to the Update Circuit Maintenances job so operators can re-fetch older notifications on demand, instead of always being limited to the normal incremental window (the timestamp of the last stored notification, or
raw_notification_initial_days_sinceon the first run).IntegerVar) — fetch notifications from the lastNdays (now - N days).StringVar, ISO 8601 date/time, e.g.2026-01-31or2026-01-31T00:00:00Z) — fetch notifications on or after that instant; assumed UTC when no timezone is given.Either input overrides the normal watermark. When both are set, the earliest start time wins ("look back at least this far"). Leave both blank for normal incremental processing. An unparseable
Fetch notifications sincevalue fails the job with a clear error rather than silently doing nothing.Re-processing already-stored notifications
A lookback window widens the range of notifications the job fetches, but
RawNotificationrecords are deduplicated by(subject, provider, stamp), so an already-stored notification is skipped even inside the window. To re-parse notifications that were stored but failed to parse (e.g. after upgradingcircuit-maintenance-parser), delete theirRawNotificationrecords first, then run the job with a lookback that covers them. This is documented in the user guide.Screenshots
Not applicable — this adds standard Nautobot-rendered inputs to an existing Job form (no custom UI).
Testing
get_since_reference(days override, datetime override, both → earliest, first-run default) and for the job failing on an invalidfetch_sincevalue; updated the existing watermark test for theintreturn type.test_handler(28) andtest_jobs(4) pass;rufflint + format clean; docs build (mkdocs strict) passes; no missing migrations.Docs
docs/user/app_use_cases.md— new "Re-fetching older notifications (lookback window)" section documenting both inputs and the delete-then-reprocess workflow.