[PR #4959] [MERGED] Closes #4639: Replace annotate_depth() on Prefix manager #12948

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/4959
Author: @jeremystretch
Created: 8/5/2020
Status: Merged
Merged: 8/6/2020
Merged by: @jeremystretch

Base: develop-2.9Head: 4639-prefix-annotate-depth


📝 Commits (5)

  • 0d68d0c Replace annotate_depth() with annotate_tree()
  • e8df9be Add LTE and GTE filters for prefix mask length
  • d384f25 Replace expand/collpase with max mask length for prefixes list
  • c36d8b2 Fix default display of child count in prefix tables
  • 0f397fa Replicate 'max length' field in PrefixFilterForm for consistency

📊 Changes

8 files changed (+91 additions, -86 deletions)

View changed files

📝 netbox/ipam/filters.py (+10 -7)
📝 netbox/ipam/forms.py (+3 -4)
📝 netbox/ipam/querysets.py (+15 -29)
📝 netbox/ipam/tables.py (+9 -7)
📝 netbox/ipam/views.py (+4 -11)
📝 netbox/templates/inc/search_panel.html (+29 -26)
📝 netbox/templates/ipam/prefix_list.html (+13 -2)
📝 netbox/utilities/templatetags/helpers.py (+8 -0)

📄 Description

Closes: #4639

  • Replace the horribly inefficient annotate_depth() method on the Prefix manager with the new annotate_tree(), which uses two subqueries to calculate the number of parent and child prefixes for only the returned results
  • Add mask_length__lte and mask_length__gte filters for the Prefix model (in addition to the current mask_length filter)
  • Ditch the expand/collapse toggle on the prefix list in favor of a more granular mechanism which filters prefixes by maximum mask length
  • Add a table column indicating the number of child prefixes which exist beneath each prefix

🔄 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/4959 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 8/5/2020 **Status:** ✅ Merged **Merged:** 8/6/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop-2.9` ← **Head:** `4639-prefix-annotate-depth` --- ### 📝 Commits (5) - [`0d68d0c`](https://github.com/netbox-community/netbox/commit/0d68d0c059f9bb162622861e7c0c482c8bc907ab) Replace annotate_depth() with annotate_tree() - [`e8df9be`](https://github.com/netbox-community/netbox/commit/e8df9be7020a9b781cc65e86e947fa9f6b9af4dc) Add LTE and GTE filters for prefix mask length - [`d384f25`](https://github.com/netbox-community/netbox/commit/d384f25ec222776cdd06c6813fae832f7a705569) Replace expand/collpase with max mask length for prefixes list - [`c36d8b2`](https://github.com/netbox-community/netbox/commit/c36d8b2256b0af2263c27193c942d04aa473fd27) Fix default display of child count in prefix tables - [`0f397fa`](https://github.com/netbox-community/netbox/commit/0f397fa41086b1fdd008464652d0c516575af29a) Replicate 'max length' field in PrefixFilterForm for consistency ### 📊 Changes **8 files changed** (+91 additions, -86 deletions) <details> <summary>View changed files</summary> 📝 `netbox/ipam/filters.py` (+10 -7) 📝 `netbox/ipam/forms.py` (+3 -4) 📝 `netbox/ipam/querysets.py` (+15 -29) 📝 `netbox/ipam/tables.py` (+9 -7) 📝 `netbox/ipam/views.py` (+4 -11) 📝 `netbox/templates/inc/search_panel.html` (+29 -26) 📝 `netbox/templates/ipam/prefix_list.html` (+13 -2) 📝 `netbox/utilities/templatetags/helpers.py` (+8 -0) </details> ### 📄 Description ### Closes: #4639 - Replace the horribly inefficient `annotate_depth()` method on the Prefix manager with the new `annotate_tree()`, which uses two subqueries to calculate the number of parent and child prefixes for only the returned results - Add `mask_length__lte` and `mask_length__gte` filters for the Prefix model (in addition to the current `mask_length` filter) - Ditch the expand/collapse toggle on the prefix list in favor of a more granular mechanism which filters prefixes by maximum mask length - Add a table column indicating the number of child prefixes which exist beneath each prefix --- <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:32 +01:00
adam closed this issue 2025-12-29 22:24:32 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12948