GrafeasGroup / blossom

The website. The app. The everything.
6 stars 3 forks source link

Replace `TimeFilter` filter backend #228

Closed TimJentzsch closed 2 years ago

TimJentzsch commented 2 years ago

Relevant issue: Closes #227.

Description:

:warning: This PR contains breaking changes! :warning:

This PR removes the TimeFilter backend and its corresponding from and until query parameters and replaces it with the built-in Django time filters.

Specifically, this adds the gte, gt, lt and lte variants of the create_time, claim_time and complete_time fields.

This gives the client more control on which time field gets filtered, as well as the exact filtering method. This will probably be useful for some Buttercup commands, e.g. filtering out posts older than 18 hours when displaying posts in the queue. Additionally, it makes the filtering consistent with the /transcription/ endpoint.

Drawbacks

It's important to note that the Django time filters can't parse all the strings that the old filter accepted. All times must include a timezone and be a valid ISO 8601 string. Relative times are not supported anymore.

However, I argue that the client can handle other kinds of input and convert it to this format. IMO the simpler design is worth it.

Migration Guide

The old from parameter corresponds to complete_time__gt and until to complete_time__lt. However, I suggest to use the gte and lte variants instead.

Checklist: