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

Add custom job intervals #2084

Merged
merged 46 commits into from
Jul 29, 2022
Merged

Add custom job intervals #2084

merged 46 commits into from
Jul 29, 2022

Conversation

yoonthegoon
Copy link
Contributor

@yoonthegoon yoonthegoon commented Jul 21, 2022

Closes: #1226

What's Changed

Adds custom cron style interval for running jobs.
image

TODO

  • Explanation of Change(s)
  • Attached Screenshots, Payload Example
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)

@yoonthegoon yoonthegoon marked this pull request as ready for review July 21, 2022 17:16
@yoonthegoon yoonthegoon marked this pull request as draft July 21, 2022 17:17
@yoonthegoon yoonthegoon marked this pull request as ready for review July 21, 2022 17:19
Copy link
Contributor

@jathanism jathanism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks! Just need some clarifications.

nautobot/extras/models/jobs.py Outdated Show resolved Hide resolved
nautobot/extras/models/jobs.py Outdated Show resolved Hide resolved
nautobot/extras/templates/extras/job.html Outdated Show resolved Hide resolved
nautobot/extras/models/jobs.py Outdated Show resolved Hide resolved
nautobot/extras/models/jobs.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@yoonthegoon yoonthegoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all changes have been made

nautobot/extras/api/views.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jathanism jathanism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great. Let's just get this tested and wrap it up, assuming my new comments aren't too much.

nautobot/extras/tests/test_views.py Outdated Show resolved Hide resolved
Comment on lines 860 to 865
return schedules.crontab(minute=t.minute, hour=t.hour)
elif self.interval == JobExecutionType.TYPE_WEEKLY:
return schedules.crontab(minute=t.minute, hour=t.hour, day_of_week=t.weekday())
elif self.interval == JobExecutionType.TYPE_CUSTOM:
return self.get_crontab(self.crontab)
raise ValueError(f"I do not know to convert {self.interval} to a Cronjob!")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to add a housekeeping item to stash the crontab onto self.crontab in all cases. Could clean up a lot of these methods.

Copy link
Member

@bryanculver bryanculver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jathanism jathanism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding the tests! I just have a couple minor asks and we're good to wrap this up!

nautobot/extras/api/nested_serializers.py Outdated Show resolved Hide resolved
nautobot/extras/api/views.py Show resolved Hide resolved
nautobot/extras/tests/test_views.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jathanism jathanism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chef's kiss 👨‍🍳 💋 Thank you for your contribution! This is great!

@yoonthegoon
Copy link
Contributor Author

thank you for the feedback. i learned a lot

@bryanculver bryanculver merged commit 7026128 into nautobot:develop Jul 29, 2022
smk4664 added a commit to smk4664/nautobot that referenced this pull request Jul 29, 2022
* next: (26 commits)
  Include relationships and associations on object REST APIs (nautobot#2092)
  Add release-note for nautobot#2116
  Update Releases Batched for Next (next) (nautobot#2116)
  Re-ordered migrations
  Add release-note for nautobot#1226, nautobot#1739, nautobot#2115
  Add custom job intervals (nautobot#2084)
  Implement Notes Model (nautobot#1984)
  Update Lock-file Patch Releases for Develop (nautobot#2115)
  update paginator to enforce max_page_size setting in web ui views (nautobot#2112)
  Add missing location status migration (nautobot#2100)
  update release-notes for issue nautobot#2060
  added peer_id filter for relationship associations (nautobot#2113)
  Add release-note for nautobot#2025
  Cleanup group names, manual approval for flake8 (nautobot#2025)
  updated documentations for nautobot#2109 and nautobot#2111
  fixed one to many relationship source filter and apply AND operator between filters (nautobot#2111)
  Version bump to v1.3.10-beta.1, seeded next version in docs.
  Add release-note for nautobot#860, nautobot#1694, nautobot#2081. Update release date, version.
  Fix nautobot#2077 - handle case on object detail views where a relationship involves a non-installed model (nautobot#2078)
  Fix error raised if status connected not found when creating a cable (nautobot#2089)
  ...

# Conflicts:
#	nautobot/circuits/api/serializers.py
#	nautobot/core/api/serializers.py
#	nautobot/dcim/api/serializers.py
#	nautobot/docs/development/best-practices.md
#	nautobot/docs/development/style-guide.md
#	nautobot/docs/release-notes/version-1.4.md
#	nautobot/extras/api/nested_serializers.py
#	nautobot/extras/api/relationships.py
#	nautobot/extras/api/serializers.py
#	nautobot/extras/tests/integration/test_notes.py
#	nautobot/extras/tests/test_api.py
#	nautobot/utilities/testing/api.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Scheduler: Enable cron style interval settings
5 participants