-
Notifications
You must be signed in to change notification settings - Fork 32
Open
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:
Line 83 in 489f024
| app.state.collection_catalog = await get_collection_index(app.state.pool, **kwargs) |
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
Lines 40 to 43 in 489f024
collection_catalog = getattr(request.app.state, "collection_catalog", {}) if collectionId in collection_catalog: return collection_catalog[collectionId] - cheap collection filtering https://github.com/developmentseed/tipg/blob/main/tipg/factory.py#L439-L458
The collection_catalog is created at application startup
Lines 65 to 80 in 489f024
| @app.on_event("startup") | |
| async def startup_event() -> None: | |
| """Connect to database on startup.""" | |
| await connect_to_db(app, settings=postgres_settings) | |
| await register_collection_catalog( | |
| app, | |
| schemas=db_settings.schemas, | |
| exclude_schemas=db_settings.exclude_schemas, | |
| tables=db_settings.tables, | |
| exclude_tables=db_settings.exclude_tables, | |
| function_schemas=db_settings.function_schemas, | |
| exclude_function_schemas=db_settings.exclude_function_schemas, | |
| functions=db_settings.functions, | |
| exclude_functions=db_settings.exclude_functions, | |
| spatial=db_settings.only_spatial_tables, | |
| ) |
The problem then (as explained in developmentseed/eoAPI#55 (comment)) 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_filterandtemporal_filter
cc @bitner
Metadata
Metadata
Assignees
Labels
No labels