openmeteo / enhydris

A database with a web interface for the storage and management of hydro/meteorological measurements and time series
GNU Affero General Public License v3.0
18 stars 11 forks source link

Cache start_date, end_date and last_update (and the _naive counterparts) #384

Closed aptiko closed 3 years ago

aptiko commented 3 years ago

Station has last_update, and TimeseriesGroup and Timeseries have start_date and end_date, and all these have a _naive version (total 10 properties). The front page, which fetches the last_update for many stations, could be quite expensive because it has to query a large number of time series. We should cache these in the Django cache.

All these caches should be invalidated in Timeseries.save().

aptiko commented 3 years ago

You'll find examples of how to unit-test this if you search test_models.py for assertNumQueries.