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

Added in environment variable for sorting/config #187

Merged
merged 7 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

Note: Minor version `0.X.0` update might break the API, It's recommended to pin `tipg` to minor version: `tipg>=0.1,<0.2`

## Unreleased

* add `TIPG_SORT_COLUMNS` settings to enable/disable columns sorting (default to `True`) (author @mattdiez-at, https://github.com/developmentseed/tipg/pull/187)

## [0.7.2] - 2024-08-27

* move back to `fastapi` dependency
Expand Down Expand Up @@ -310,7 +314,7 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin
- Initial release

[unreleased]: https://github.com/developmentseed/tipg/compare/0.7.2...HEAD
[0.7.1]: https://github.com/developmentseed/tipg/compare/0.7.1...0.7.2
[0.7.2]: https://github.com/developmentseed/tipg/compare/0.7.1...0.7.2
[0.7.1]: https://github.com/developmentseed/tipg/compare/0.7.0...0.7.1
[0.7.0]: https://github.com/developmentseed/tipg/compare/0.6.3...0.7.0
[0.6.3]: https://github.com/developmentseed/tipg/compare/0.6.2...0.6.3
Expand Down
1 change: 1 addition & 0 deletions docs/src/user_guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ prefix: **`TIPG_`**

- **DATETIME_EXTENT** (bool): Fetch datetime extent by going throught all rows. Default is `True`
- **FALLBACK_KEY_NAMES** (list of string): Primary Key names to look for in the tables. Default is `["ogc_fid", "id", "pkey", "gid"]`
- **SORT_COLUMNS** (bool): Sort the `columns` for a table alphabetically. Default is `True`.
- **TABLE_CONFIG** (dict of `TableConfig`)
- **TABLE_CONFIG_ _ {schemaId}_{tableId} _ _GEOMCOL** (str): Table's geometry/geography column name
- **TABLE_CONFIG_ _ {schemaId}_{tableId} _ _DATETIMECOL** (str): Table's datetime column name
Expand Down
5 changes: 4 additions & 1 deletion tipg/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,10 @@ async def get_collection_index( # noqa: C901
table_conf = table_confs.get(confid, TableConfig())

# Make sure that any properties set in conf exist in table
columns = sorted(table.get("properties", []), key=lambda d: d["name"])
columns = table.get("properties", [])
if table_settings.sort_columns:
columns = sorted(columns, key=lambda d: d["name"])

properties_setting = table_conf.properties or [c["name"] for c in columns]

# ID Column
Expand Down
1 change: 1 addition & 0 deletions tipg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TableSettings(BaseSettings):

fallback_key_names: List[str] = ["ogc_fid", "id", "pkey", "gid"]
table_config: Dict[str, TableConfig] = {}
sort_columns: bool = True

model_config = {
"env_prefix": "TIPG_",
Expand Down