Skip to content

Commit 2f24b79

Browse files
committed
Fix bug
1 parent 372cba5 commit 2f24b79

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ class JobPaginationDefaultQueryArgs(PaginationDefaultQueryArgs):
453453
retries_greater_than: Literal[0, 1, 2, 3] | None
454454
retries_equal_to: Literal[0, 1, 2, 3, 4] | None
455455

456-
async def job_pagination_default_query_args(page: Page = 1, after: datetime.datetime | None = None, desc: bool = False, not_started: bool = False, completed: bool = False, delayed: bool = False, failed: bool = False, retries_less_than: Literal[1, 2, 3, 4] | None = None, retries_greater_than: Literal[0, 1, 2, 3] | None = None, retries_equal_to: Literal[0, 1, 2, 3, 4] | None = None) -> JobPaginationDefaultQueryArgs:
456+
async def job_pagination_default_query_args(page: Page = 1, after: datetime.datetime | None = None, desc: bool = False, not_started: bool = True, completed: bool = True, delayed: bool = True, failed: bool = True, retries_less_than: Literal[1, 2, 3, 4] | None = None, retries_greater_than: Literal[0, 1, 2, 3] | None = None, retries_equal_to: Literal[0, 1, 2, 3, 4] | None = None) -> JobPaginationDefaultQueryArgs:
457457
return {
458458
"page": page,
459459
"after": after,
@@ -475,7 +475,7 @@ def apply_job_filtering(query_params: JobPaginationDefaultQueryArgs, is_count_qu
475475
def apply_job_filtering(query_params: JobPaginationDefaultQueryArgs, is_count_query: Literal[False], /) -> sqlalchemy.Select[tuple[Job]]: ...
476476
def apply_job_filtering(query_params: JobPaginationDefaultQueryArgs, is_count_query: bool = False, /) -> sqlalchemy.Select:
477477
in_statement = select(sqlalchemy.func.count(Job.id) if is_count_query else Job)
478-
if [query_params["not_started"], query_params["completed"], query_params["delayed"], query_params["failed"]].count(True) != 4:
478+
if len({query_params["not_started"], query_params["completed"], query_params["delayed"], query_params["failed"]}) != 1: # If they are all the same, we can take a shortcut and not apply anything
479479
# If all 4 are given, we can take a shortcut and not apply anything
480480
if query_params["not_started"]:
481481
in_statement = in_statement.where((Job.completed == None) & (Job.failed == None) & (Job.delayed_until == None))

0 commit comments

Comments
 (0)