Skip to content

Conversation

@pheus
Copy link
Contributor

@pheus pheus commented Oct 30, 2025

Fixes: #19523

Summary (draft)
Implement usage count filtering via counter caches:

  • Add device_count to DeviceType and module_count to ModuleType using CounterCacheField
  • Expose numeric lookups in REST and GraphQL (e.g., device_count__gte=…, deviceCount: { gte: … }).
  • Keep existing naming (device_count) as discussed; introduce module_count for consistency.

Note on receivers (included so CI passes on feature)
This draft includes the per‑sender dispatch_uid change to utilities.counters.connect_counters() to prevent duplicate signal registration (see #20697). I’ll rebase/drop this once #20697 merges to main.

Status
Tests are pending! Opening as a draft to validate the approach and naming before finalizing.

pheus added 2 commits October 30, 2025 13:47
Introduces `device_count` and `module_count` filters to enable
queries based on the existence and count of the associated device or
module instances.
Updates forms, filtersets, and GraphQL schema to support these filters,
along with comprehensive tests for validation.

Fixes netbox-community#19523
Updates `connect_counters` to prevent duplicate signal handlers by
using consistent `dispatch_uid` values per sender. Adds a check to
avoid reconnecting models already processed during registration.
@jeremystretch jeremystretch self-requested a review October 31, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant