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 2 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
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", [])
mattdiez-at marked this conversation as resolved.
Show resolved Hide resolved

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
vincentsarago marked this conversation as resolved.
Show resolved Hide resolved
vincentsarago marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down