Created
October 20, 2024 01:49
-
-
Save colonelpanic8/1209b73d60b64001c46db85c1300a890 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_lexical_condition( | |
ordering_components: list[gql.ShotsOrderingComponent], | |
) -> sa.sql.elements.BooleanClauseList: | |
if not ordering_components: | |
return False | |
this_component = ordering_components[0] | |
_, field, ordering = this_component.get_component_with_column() | |
this_condition = ( | |
field < ordering.starting_at | |
if ordering.descending | |
else field > ordering.starting_at | |
) | |
remaining_components = ordering_components[1:] | |
rest_conditions = [field == ordering.starting_at] | |
if remaining_components: | |
rest_conditions.append(build_lexical_condition(remaining_components)) | |
return sa.or_( | |
this_condition, | |
(sa.and_(*rest_conditions)), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment