[PR #4799] [MERGED] 2006 scripts reports background #12921

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/4799
Author: @lampwins
Created: 6/29/2020
Status: Merged
Merged: 7/6/2020
Merged by: @jeremystretch

Base: develop-2.9Head: 2006-scripts-reports-background


📝 Commits (10+)

  • 3777fbc Implements #2006 - run reports and scripts in the background
  • 1681dbf refactor migration
  • f48a079 fix tests and cleanup
  • 1d922a1 fix previous job result deletion
  • f98fa36 Merge branch 'develop-2.9' into 2006-scripts-reports-background
  • f092c10 PR review updates
  • 41f92ef review updates
  • 4a74927 Merge branch 'develop-2.9' into 2006-scripts-reports-background
  • 6547a2b merge conflict
  • 4ea4112 Fix up schema migration; PEP8 cleanup

📊 Changes

32 files changed (+1193 additions, -362 deletions)

View changed files

📝 netbox/extras/admin.py (+6 -15)
📝 netbox/extras/api/nested_serializers.py (+11 -10)
📝 netbox/extras/api/serializers.py (+32 -20)
📝 netbox/extras/api/urls.py (+3 -0)
📝 netbox/extras/api/views.py (+85 -18)
📝 netbox/extras/choices.py (+64 -0)
📝 netbox/extras/constants.py (+2 -15)
📝 netbox/extras/filters.py (+31 -1)
netbox/extras/migrations/0043_report.py (+22 -0)
netbox/extras/migrations/0044_jobresult.py (+75 -0)
📝 netbox/extras/models/__init__.py (+4 -3)
📝 netbox/extras/models/models.py (+93 -13)
📝 netbox/extras/reports.py (+60 -20)
📝 netbox/extras/scripts.py (+50 -22)
📝 netbox/extras/templatetags/log_levels.py (+4 -24)
📝 netbox/extras/tests/test_api.py (+35 -8)
📝 netbox/extras/urls.py (+4 -3)
📝 netbox/extras/views.py (+150 -53)
📝 netbox/netbox/views.py (+11 -2)
netbox/project-static/js/job_result.js (+47 -0)

...and 12 more files

📄 Description

Fixes: #2006

This is a first pass on running script and reports in the background. Both scripts and reports are backed by the new JobResult model which fully replaces the ReportResult model, with additional functionality.

You will note some slight UX differences between scripts and reports. When running a report, the user is directed to the normal report results page which displays the most recent complete job's results. UI elements like the status label and pinwheel indicate the status of the new job. When complete, a button is presented that will refresh the page to display the new results. Scripts on the other hand will refresh the page automatically because previous (current) results are not displayed. I chose to do this based on the context of reports and not wanted to disrupt current results during long-running jobs.

Naturally, this implementation will fit well with historical results, should we choose to do that at some point. Currently, the previous results (JobResult instances) are deleted after the new job is complete.


🔄 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/4799 **Author:** [@lampwins](https://github.com/lampwins) **Created:** 6/29/2020 **Status:** ✅ Merged **Merged:** 7/6/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop-2.9` ← **Head:** `2006-scripts-reports-background` --- ### 📝 Commits (10+) - [`3777fbc`](https://github.com/netbox-community/netbox/commit/3777fbccc3ad504c50da2d3556f119565960dbd8) Implements #2006 - run reports and scripts in the background - [`1681dbf`](https://github.com/netbox-community/netbox/commit/1681dbfa39b9d45791a6b49411b45669e8c4ec6d) refactor migration - [`f48a079`](https://github.com/netbox-community/netbox/commit/f48a079ae61acb2a0a3e7c381d650935036bcd74) fix tests and cleanup - [`1d922a1`](https://github.com/netbox-community/netbox/commit/1d922a18486236257f2582b60948db8c76c279ef) fix previous job result deletion - [`f98fa36`](https://github.com/netbox-community/netbox/commit/f98fa364c0f6c474072218e31a2f82e69ba5cfc6) Merge branch 'develop-2.9' into 2006-scripts-reports-background - [`f092c10`](https://github.com/netbox-community/netbox/commit/f092c107b541838b550b85777cf4781f82cb16fb) PR review updates - [`41f92ef`](https://github.com/netbox-community/netbox/commit/41f92ef8e65ea0f975bb0b80195fb64b59fcd82b) review updates - [`4a74927`](https://github.com/netbox-community/netbox/commit/4a74927fa2e96f411b781799b6b72a1bb4e3aaa4) Merge branch 'develop-2.9' into 2006-scripts-reports-background - [`6547a2b`](https://github.com/netbox-community/netbox/commit/6547a2bc501353cde8a217c4267d3f6e246eca86) merge conflict - [`4ea4112`](https://github.com/netbox-community/netbox/commit/4ea411249032b606efaf9ed99f5e0656f6cf6eaa) Fix up schema migration; PEP8 cleanup ### 📊 Changes **32 files changed** (+1193 additions, -362 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/admin.py` (+6 -15) 📝 `netbox/extras/api/nested_serializers.py` (+11 -10) 📝 `netbox/extras/api/serializers.py` (+32 -20) 📝 `netbox/extras/api/urls.py` (+3 -0) 📝 `netbox/extras/api/views.py` (+85 -18) 📝 `netbox/extras/choices.py` (+64 -0) 📝 `netbox/extras/constants.py` (+2 -15) 📝 `netbox/extras/filters.py` (+31 -1) ➕ `netbox/extras/migrations/0043_report.py` (+22 -0) ➕ `netbox/extras/migrations/0044_jobresult.py` (+75 -0) 📝 `netbox/extras/models/__init__.py` (+4 -3) 📝 `netbox/extras/models/models.py` (+93 -13) 📝 `netbox/extras/reports.py` (+60 -20) 📝 `netbox/extras/scripts.py` (+50 -22) 📝 `netbox/extras/templatetags/log_levels.py` (+4 -24) 📝 `netbox/extras/tests/test_api.py` (+35 -8) 📝 `netbox/extras/urls.py` (+4 -3) 📝 `netbox/extras/views.py` (+150 -53) 📝 `netbox/netbox/views.py` (+11 -2) ➕ `netbox/project-static/js/job_result.js` (+47 -0) _...and 12 more files_ </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be opened for approval prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. Please indicate the relevant feature request or bug report below. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ACCEPTED BUG REPORT OR FEATURE REQUEST, IT WILL BE MARKED AS INVALID AND CLOSED. --> ### Fixes: #2006 <!-- Please include a summary of the proposed changes below. --> This is a first pass on running script and reports in the background. Both scripts and reports are backed by the new `JobResult` model which fully replaces the `ReportResult` model, with additional functionality. You will note some slight UX differences between scripts and reports. When running a report, the user is directed to the normal report results page which displays the most recent complete job's results. UI elements like the status label and pinwheel indicate the status of the new job. When complete, a button is presented that will refresh the page to display the new results. Scripts on the other hand will refresh the page automatically because previous (current) results are not displayed. I chose to do this based on the context of reports and not wanted to disrupt current results during long-running jobs. Naturally, this implementation will fit well with historical results, should we choose to do that at some point. Currently, the previous results (JobResult instances) are deleted after the new job is complete. --- <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 22:24:23 +01:00
adam closed this issue 2025-12-29 22:24:23 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12921