Closes #19523: Add counter‑cached counts & filters for DeviceType, ModuleType, and RackType #943

Closed
opened 2026-04-05 19:05:38 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 10/30/2025

Fixes: #19523

Summary
Extend usage-count filtering via counter caches to cover DeviceType, ModuleType, and RackType.

Implementation

  • Add counter‑cached integer fields:
    • device_count on DeviceType
    • module_count on ModuleType
    • rack_count on RackType
  • Expose numeric lookups in REST and GraphQL (e.g., device_count__gte=10, module_count=0, {rack_count: {gt: 2}).
  • Include migration to add fields and backfill counts.
  • Add a test.

Database Changes
Adds integer fields on the three models listed above.

*Originally created by @pheus on 10/30/2025* <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #19523 **Summary** Extend usage-count filtering via counter caches to cover **DeviceType**, **ModuleType**, and **RackType**. **Implementation** - Add counter‑cached integer fields: - `device_count` on **DeviceType** - `module_count` on **ModuleType** - `rack_count` on **RackType** - Expose numeric lookups in **REST** and **GraphQL** (e.g., `device_count__gte=10`, `module_count=0`, `{rack_count: {gt: 2}`). - Include migration to add fields and backfill counts. - Add a test. **Database Changes** Adds integer fields on the three models listed above.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#943