-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closes #19523: Add counter‑cached counts & filters for DeviceType, ModuleType, and RackType #20718
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
base: feature
Are you sure you want to change the base?
Conversation
jeremystretch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @pheus!
cb711da to
50a63be
Compare
|
Thanks for the thoughtful review and the migration tip - much appreciated! I’ve added a data migration to prefill |
|
I just noticed an earlier FR comment asking to extend this to RackType as well - sorry I missed that. I’m happy to apply the same approach to |
|
@pheus I think it makes sense to fold that in here as well, since it's a continuation of the same pattern. Thanks! |
50a63be to
5eecaa0
Compare
| from .devices import Device, Module | ||
| from .devices import Device | ||
| from .modules import Module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Unrelated import fix. Happy to drop this if you'd prefer to keep the PR focused.
| def get_available_units(self, u_height=1, rack_face=None, exclude=None, ignore_excluded_devices=False): | ||
| def get_available_units(self, u_height=1.0, rack_face=None, exclude=None, ignore_excluded_devices=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Unrelated cleanup. Happy to drop this if you'd prefer to keep the PR focused.
Introduces `device_count`, `module_count` and `rack_count` filters to enable queries based on the existence and count of the associated device, module or rack instances. Updates forms, filtersets, and GraphQL schema to support these filters, along with tests for validation. Fixes netbox-community#19523
5eecaa0 to
d14e741
Compare
|
Thanks! I’ve applied the same approach to |
Fixes: #19523
Summary
Extend usage-count filtering via counter caches to cover DeviceType, ModuleType, and RackType.
Implementation
device_counton DeviceTypemodule_counton ModuleTyperack_counton RackTypedevice_count__gte=10,module_count=0,{rack_count: {gt: 2}).Database Changes
Adds integer fields on the three models listed above.