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

Support time range constraints for changelog in API #1146

Closed
jakubkrysl opened this issue Dec 10, 2021 · 3 comments · Fixed by #1596
Closed

Support time range constraints for changelog in API #1146

jakubkrysl opened this issue Dec 10, 2021 · 3 comments · Fixed by #1596
Labels
type: feature Introduction of new or enhanced functionality to the application

Comments

@jakubkrysl
Copy link

User Story

As Arthur the API user...,

I want to get changes done over some period...,

So that I don't I don't have to fetch all (600k) object changes…,

I will know this is done when API supports time range constraints in any form (before/after, time__lt/time__gt...).

Note: It is already possible in UI.
image

Database Changes

None

External Dependencies

None

@glennmatthews glennmatthews added group: misc type: feature Introduction of new or enhanced functionality to the application labels Dec 13, 2021
@scetron
Copy link
Contributor

scetron commented Mar 3, 2022

Hello @Thetacz, if you are using the API, you can use the q query in the following form:

q=&time_after=2021-03-03 12:00:00&time_before=2022-03-03 12:00:00

So in this case, you can try this URL:

http://demo.nautobot.com/api/extras/object-changes/?q=&time_after=2021-03-03 12:00:00&time_before=2022-03-03 12:00:00

Does this work for your use case? Keep in mind, when using the filter, it appears that you have to specify a time range, rather than just before or after.

@joewesch
Copy link
Contributor

joewesch commented Mar 3, 2022

I believe you can enable the individual before & after filters if you specify the lte/gte methods in addition to this line:

time = django_filters.DateTimeFromToRangeFilter()

time__gte = django_filters.DateTimeFilter(field_name="time", lookup_expr="gte")
time__lte = django_filters.DateTimeFilter(field_name="time", lookup_expr="lte")

@scetron
Copy link
Contributor

scetron commented Mar 3, 2022

Thanks @joewesch, actually, explicitly adding those to the FilterSet allows it to be used in GraphQL as well. I'll add that as time_before and time_after.

bryanculver added a commit that referenced this issue Apr 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Introduction of new or enhanced functionality to the application
Projects
None yet
4 participants