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

Add support for time attribute predicates #237

Open
ellmetha opened this issue May 26, 2024 · 0 comments
Open

Add support for time attribute predicates #237

ellmetha opened this issue May 26, 2024 · 0 comments
Milestone

Comments

@ellmetha
Copy link
Member

Description

Let's make it easier to filter time fields through query sets by adding support for a set of new predicates that will allow to filter based on specific time attributes.

New predicates

year

The new year predicate should allow filtering date_time and date fields based on a specific year:

Book.filter(created_at__year: 2024)

month

The new month predicate should allow filtering date_time and date fields based on a specific month (with 1 being and January and 12 being December):

Book.filter(created_at__month: 12)

day

The new day predicate should allow filtering date_time and date fields based on a specific day number (regardless of the actual month):

Book.filter(created_at__day: 28)

hour

The new hour predicate should allow filtering date_time fields based on a specific hour value (integer between 0 and 23):

Book.filter(created_at__hour: 23)

minute

The new minute predicate should allow filtering date_time fields based on a specific minute value (integer between 0 and 59):

Book.filter(created_at__minute: 55)

second

The new second predicate should allow filtering date_time fields based on a specific second value (integer between 0 and 59):

Book.filter(created_at__second: 45)

Chaining of predicates

The introduction of these new predicates could also be accompanied by the support for chaining query set predicates. This is especially relevant for time attribute filtering where it's common to target records for which a specific time property is greater than or less than a give number.

As such, we should also explore enabling the use of chained query set predicates for the new time predicates that will be introduced here. For example:

Book.filter(created_at__year__gte: 2022)
@ellmetha ellmetha added this to the v0.6.0 milestone Jul 11, 2024
@ellmetha ellmetha assigned ellmetha and unassigned ellmetha Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant