Skip to content

Commit

Permalink
Added in environment variable for sorting/config
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdiez-at committed Aug 27, 2024
1 parent c9e140f commit 0ad4b14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/user_guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ prefix: **`TIPG_`**

- **DEFAULT_FEATURES_LIMIT** (int): Set the default `Limit` values for `/items` endpoint. Default is `10`
- **MAX_FEATURES_PER_QUERY** (int): Set the maximum number of features the `/items` endpoint can return. Default is `10000`.
- **SORT_COLUMNS** (bool): Sort the `columns` for a feature alphabetically. Default is `True`.

```bash
TIPG_DEFAULT_FEATURES_LIMIT=1000 TIPG_MAX_FEATURES_PER_QUERY=2000
Expand Down
6 changes: 5 additions & 1 deletion tipg/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,11 @@ 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"])
if features_settings.sort_columns:
columns = sorted(table.get("properties", []), key=lambda d: d["name"])
else:
columns = table.get("properties", [])

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 @@ -86,6 +86,7 @@ class FeaturesSettings(BaseSettings):

default_features_limit: int = Field(10, ge=0)
max_features_per_query: int = Field(10000, ge=0)
sort_columns: bool = True

model_config = {"env_prefix": "TIPG_", "env_file": ".env", "extra": "ignore"}

Expand Down

0 comments on commit 0ad4b14

Please sign in to comment.