Skip to content

feat(entity.py): {etype}/get sorting#41

Open
softlukas wants to merge 1 commit into
masterfrom
dp3_api_filtering
Open

feat(entity.py): {etype}/get sorting#41
softlukas wants to merge 1 commit into
masterfrom
dp3_api_filtering

Conversation

@softlukas
Copy link
Copy Markdown
Collaborator

sorting implementation entity/{etype}/get in dp3 api, please check if all conditions which raise exeption is correct, or if some check not missing

@softlukas softlukas requested a review from xsedla1o June 3, 2026 14:11
@softlukas softlukas force-pushed the dp3_api_filtering branch from d19d81a to 5ac5329 Compare June 3, 2026 14:51
Copy link
Copy Markdown
Collaborator

@xsedla1o xsedla1o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for the most part, minor issues in comments bellow.

Comment thread dp3/api/routers/entity.py
)

data_type_str = str(attr_spec.data_type)
allowed_primitives = set(primitive_data_types.keys()) - {"json"}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a "special" type in primitive_data_types, which should be excluded as well.

Comment thread dp3/api/routers/entity.py

def _validate_sort_params(
etype: str, sort_by: str | None, sort_order: int | None
) -> tuple[str | None, int]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of tuple[str | None, int] as a return type, because that means you have to unpack the tuple correctly and then check for None to see if any sorting is actually hapenning. As it stands now, the returned sort_order value must also be ignored in the no sort case, because it is never validated.
It would make more sense to me to return tuple[str, int] | None, where you can just check for None straight away and there is no mixed invalid state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants