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

Add sortable=True to all properties #274

Merged
merged 1 commit into from
May 18, 2020
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
2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@
"sortable": {
"title": "Sortable",
"type": "boolean",
"description": "defines whether the entry property can be used for sorting with the \"sort\" parameter. If the entry listing endpoint supports sorting, this key MUST be present for all properties."
"description": "defines whether the entry property can be used for sorting with the \"sort\" parameter. If the entry listing endpoint supports sorting, this key MUST be present for sortable properties with value `true`."
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion optimade/models/entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ class EntryInfoProperty(BaseModel):

sortable: Optional[bool] = Field(
None,
description='defines whether the entry property can be used for sorting with the "sort" parameter. If the entry listing endpoint supports sorting, this key MUST be present for all properties.',
description='defines whether the entry property can be used for sorting with the "sort" parameter. '
"If the entry listing endpoint supports sorting, this key MUST be present for sortable properties with value `true`.",
)


Expand Down
3 changes: 3 additions & 0 deletions optimade/server/routers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ def retrieve_queryable_properties(schema: dict, queryable_properties: list) -> d
properties[name] = {"description": value.get("description", "")}
if "unit" in value:
properties[name]["unit"] = value["unit"]
# All properties are sortable with the MongoDB backend.
# While the result for sorting lists may not be as expected, they are still sorted.
properties[name]["sortable"] = True
return properties


Expand Down