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

Adding ETag support for /api/albums/date/list/ endpoints #1177

Open
savvasdalkitsis opened this issue Mar 18, 2024 · 2 comments
Open

Adding ETag support for /api/albums/date/list/ endpoints #1177

savvasdalkitsis opened this issue Mar 18, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@savvasdalkitsis
Copy link
Contributor

Describe the enhancement you'd like
UhuruPhotos currently has a recurring job (by default needing charging) to fetch all the photo summaries of the user's 'feed' using the /api/albums/date/list/ and /api/albums/date/list/{id} endpoints.

The reason for that is that there is no way for the app to know if the user has added media on the server that belong to a much earlier date, therefore a deep sync is needed to make sure the app isn't missing data.

Describe why this will benefit the LibrePhotos

I think adding support for ETags on the above endpoints would allow the clients to perform syncs with minimal overhead

Additional context
https://docs.djangoproject.com/en/5.0/topics/conditional-view-processing/

@savvasdalkitsis savvasdalkitsis added the enhancement New feature or request label Mar 18, 2024
@derneuere
Copy link
Member

We use Django Rest Framework, which does not work in the same ways as regular Django views. I researched a bit, but it looks to me like a similar thing is not implemented in the framework itself, but only with third party libraries, which are not maintained.

Your request sounds to me like you want a parameter for last modified for both endpoints.

In order to implement that, we can either add a last_modified_field, which we update on every save of the model, similar to saving EXIF data back, or we can add something like https://github.com/jazzband/django-simple-history to provide a complete history and an option to revert to a previous model state.

Is there a need for having a complete history, or do you think just adding a new parameter to the endpoints and a new field is enough? Do you just need new photos or also updated photos? How do you handle deleted photos?

@savvasdalkitsis
Copy link
Contributor Author

savvasdalkitsis commented Mar 24, 2024

I would imagine a last updated would work for the main endpoint but not much use in the individual ones since I would need to get them to check the date anyway so at that point I already have the latest version.

The point of the etag is that client libraries automatically support it and the server can skip sending the body (and more importantly skip any dB lookups) if the client already has the latest version. Making the calls much faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants