[PR #10417] [MERGED] Fixes #8366 - Add job scheduling #13623

Closed
opened 2025-12-29 23:19:55 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/10417
Author: @kkthxbye-code
Created: 9/20/2022
Status: Merged
Merged: 10/21/2022
Merged by: @jeremystretch

Base: featureHead: 8366-job-scheduling


📝 Commits (10+)

  • 824b4e0 Add scheduling for reports and scripts
  • 25ac1ed Merge branch 'netbox-community:develop' into 8366-job-scheduling
  • c8671ce Update yarn.lock (flatpickr bump)
  • cbb3378 Job Scheduling WIP
  • 06dea8e WIP: Moving JobResults out of the admin panel
  • 53c8a48 Merge branch 'feature' into 8366-job-scheduling
  • 679a9e8 Work on job scheduling:
  • ef0b455 Called super delete method before deleting JobResult task.
  • 1d9808a Added scheduled_time field to JobResult model
  • d647983 Always activate scheduler functionality when running the rqworker management command

📊 Changes

27 files changed (+353 additions, -74 deletions)

View changed files

📝 docs/customization/custom-scripts.md (+3 -1)
📝 docs/customization/reports.md (+3 -1)
📝 netbox/extras/admin.py (+0 -21)
📝 netbox/extras/api/serializers.py (+7 -1)
📝 netbox/extras/api/views.py (+20 -11)
📝 netbox/extras/choices.py (+2 -0)
📝 netbox/extras/filtersets.py (+29 -2)
📝 netbox/extras/forms/filtersets.py (+53 -0)
netbox/extras/forms/reports.py (+16 -0)
📝 netbox/extras/forms/scripts.py (+12 -4)
📝 netbox/extras/management/commands/housekeeping.py (+1 -1)
📝 netbox/extras/management/commands/rqworker.py (+2 -0)
netbox/extras/migrations/0079_change_jobresult_order.py (+17 -0)
netbox/extras/migrations/0080_add_jobresult_scheduled_time.py (+18 -0)
📝 netbox/extras/models/models.py (+31 -4)
📝 netbox/extras/reports.py (+0 -1)
📝 netbox/extras/tables/tables.py (+22 -0)
📝 netbox/extras/urls.py (+5 -0)
📝 netbox/extras/views.py (+54 -17)
📝 netbox/netbox/navigation/menu.py (+5 -0)

...and 7 more files

📄 Description

Fixes: #8366

This is a draft PR for adding job scheduling. Feel free to provide input.

Changes:

  • Add a "Schedule at" form field to both the report and script form
  • Add JobResult list view
  • Add the form-object-edit class to both forms to match the width of forms in the rest of netbox (previously they were full width)
  • Update the js flatpickr dependency to fix issue with the DateTimeField automatically populating when losing focus.
  • Modify JobResult to delete RQ tasks to avoid running scheduled tasks with no JobResult associated
  • Added new JobResultStatusChoice Scheduled
  • Added new field scheduled_time to JobResult model
  • Show scheduled time when viewing a job result
  • Add --with-scheduler option to rqworker management command
  • Added small snippet to docs about scheduling jobs
  • REST API changes:
    • Added scheduled_time to JobResult

To do:

  • Add job scheduling support to the API as well?
  • limit_choices_to=FeatureQuery('job_results'), doesn't work at all in filter forms and it doesn't seem to work in other filterforms either.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/10417 **Author:** [@kkthxbye-code](https://github.com/kkthxbye-code) **Created:** 9/20/2022 **Status:** ✅ Merged **Merged:** 10/21/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `8366-job-scheduling` --- ### 📝 Commits (10+) - [`824b4e0`](https://github.com/netbox-community/netbox/commit/824b4e0923f5d215153cf8623c5f20fc7190f857) Add scheduling for reports and scripts - [`25ac1ed`](https://github.com/netbox-community/netbox/commit/25ac1edb4859d9341a05680371588d86885a49e1) Merge branch 'netbox-community:develop' into 8366-job-scheduling - [`c8671ce`](https://github.com/netbox-community/netbox/commit/c8671ce8e823bcd450855c37a0a237008cfca69f) Update yarn.lock (flatpickr bump) - [`cbb3378`](https://github.com/netbox-community/netbox/commit/cbb3378d10adc6ca72de64c976bb6b4d5385444c) Job Scheduling WIP - [`06dea8e`](https://github.com/netbox-community/netbox/commit/06dea8ef3f53b08c85f4ac17c04f71520d868bb3) WIP: Moving JobResults out of the admin panel - [`53c8a48`](https://github.com/netbox-community/netbox/commit/53c8a4824469c5d6fb495fc632a642a57cf4e672) Merge branch 'feature' into 8366-job-scheduling - [`679a9e8`](https://github.com/netbox-community/netbox/commit/679a9e839b48cc8014203cc19090361f001b9bb0) Work on job scheduling: - [`ef0b455`](https://github.com/netbox-community/netbox/commit/ef0b455b05ca50746c09017c5adea21156628169) Called super delete method before deleting JobResult task. - [`1d9808a`](https://github.com/netbox-community/netbox/commit/1d9808a92a1128894e0ffeea206ec3a721d1694c) Added scheduled_time field to JobResult model - [`d647983`](https://github.com/netbox-community/netbox/commit/d647983003e7c0753d29fdec7e308ea8f587b385) Always activate scheduler functionality when running the rqworker management command ### 📊 Changes **27 files changed** (+353 additions, -74 deletions) <details> <summary>View changed files</summary> 📝 `docs/customization/custom-scripts.md` (+3 -1) 📝 `docs/customization/reports.md` (+3 -1) 📝 `netbox/extras/admin.py` (+0 -21) 📝 `netbox/extras/api/serializers.py` (+7 -1) 📝 `netbox/extras/api/views.py` (+20 -11) 📝 `netbox/extras/choices.py` (+2 -0) 📝 `netbox/extras/filtersets.py` (+29 -2) 📝 `netbox/extras/forms/filtersets.py` (+53 -0) ➕ `netbox/extras/forms/reports.py` (+16 -0) 📝 `netbox/extras/forms/scripts.py` (+12 -4) 📝 `netbox/extras/management/commands/housekeeping.py` (+1 -1) 📝 `netbox/extras/management/commands/rqworker.py` (+2 -0) ➕ `netbox/extras/migrations/0079_change_jobresult_order.py` (+17 -0) ➕ `netbox/extras/migrations/0080_add_jobresult_scheduled_time.py` (+18 -0) 📝 `netbox/extras/models/models.py` (+31 -4) 📝 `netbox/extras/reports.py` (+0 -1) 📝 `netbox/extras/tables/tables.py` (+22 -0) 📝 `netbox/extras/urls.py` (+5 -0) 📝 `netbox/extras/views.py` (+54 -17) 📝 `netbox/netbox/navigation/menu.py` (+5 -0) _...and 7 more files_ </details> ### 📄 Description ### Fixes: #8366 This is a draft PR for adding job scheduling. Feel free to provide input. Changes: * Add a "Schedule at" form field to both the report and script form * Add JobResult list view * Add the `form-object-edit` class to both forms to match the width of forms in the rest of netbox (previously they were full width) * Update the js `flatpickr` dependency to fix issue with the DateTimeField automatically populating when losing focus. * Modify JobResult to delete RQ tasks to avoid running scheduled tasks with no JobResult associated * Added new JobResultStatusChoice `Scheduled` * Added new field `scheduled_time` to JobResult model * Show scheduled time when viewing a job result * Add --with-scheduler option to rqworker management command * Added small snippet to docs about scheduling jobs * REST API changes: * Added scheduled_time to JobResult To do: * Add job scheduling support to the API as well? * `limit_choices_to=FeatureQuery('job_results'),` doesn't work at all in filter forms and it doesn't seem to work in other filterforms either. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 23:19:55 +01:00
adam closed this issue 2025-12-29 23:19:55 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13623