developmentseed / developmentseed/tipg
stateless tipg: remove `collection_catalog`
- Dominant language
- PLpgSQL
- Stars
- 219
- Forks
- 39
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 6
Description
Since the start of tifeature/timvt/tipg, we designed the application with having a list of the available collections/layers stored in the application `State`: https://github.com/developmentseed/tipg/blob/489f0243b0b4f0d46d12f06a1baf0bccc1d4232a/tipg/db.py#L83
This gave some advantages:
- cost of running the collection listing is only paid once (at startup)
- we know what are the available collection so we can raise useful error if the user input collection is not in the list https://github.com/developmentseed/tipg/blob/489f0243b0b4f0d46d12f06a1baf0bccc1d4232a/tipg/dependencies.py#L40-L43
- cheap collection filtering https://github.com/developmentseed/tipg/blob/main/tipg/factory.py#L439-L458
The `collection_catalog` is created at application startup https://github.com/developmentseed/tipg/blob/489f0243b0b4f0d46d12f06a1baf0bccc1d4232a/tipg/main.py#L65-L80 because we assumed it's a pretty costly process.
The problem then (as explained in https://github.com/developmentseed/eoAPI/pull/55#issuecomment-1471006644) is when you have changed in the DB (e.g new table) it won't show up in the application because the catalog is now updated.
## Proposal
- remove `collection_catalog`
- create a clean SQL function which will list the collections
- the function should accept `id` (to return only one collection), `limit`, `offset`, `spatial_filter` and `temporal_filter`
cc @bitner
Contributor guide
Assessment
This issue has not been assessed yet.