Skip to content
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

Ability to filter objects by an associated request ID #11494

Closed
jeremystretch opened this issue Jan 13, 2023 · 0 comments
Closed

Ability to filter objects by an associated request ID #11494

jeremystretch opened this issue Jan 13, 2023 · 0 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@jeremystretch
Copy link
Member

NetBox version

v3.4.2

Feature type

New functionality

Proposed functionality

Add new filters to NetBoxModelFilterSet which enable a user to filter for objects based on the ID and action of an associated change record. For example, suppose you want to find all sites that were created as the result of a specific request. This proposal would enable you to filter send a request such as:

GET /dcim/sites/?objectchange_request_id=e39c84bc-f169-4d5f-bc1c-94487a1b18b5

This filter would perform two lookups:

  1. Find all ObjectChanges with the specified request ID pertaining to site objects, and return a list containing the ID of each site.
  2. Return a queryset containing all sites matched by the list of IDs.

Although we're making two queries, overhead shouldn't be too bad as the first is returning only the related object IDs. However we probably want to add a database index for the request_id column.

(I'm open to suggestions regarding the specific filter name. I'd like to avoid using the term "change request" as that could be very confusing to the user.)

Use case

The initial catalyst for this idea came from #10242, which seeks to optimize our approach for returning newly-imported objects. However, this functionality will likely find many additional use cases.

Shout-out to @DanSheps who first proposed this strategy.

Database changes

Add an index for extras_objectchange.request_id to optimize queries. This can be accomplished using a simple migration.

External dependencies

No response

@jeremystretch jeremystretch added type: feature Introduction of new functionality to the application status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Jan 13, 2023
@jeremystretch jeremystretch self-assigned this Mar 16, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Mar 16, 2023
@jeremystretch jeremystretch added this to the v3.5 milestone Mar 16, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

1 participant