Skip to content

Commit

Permalink
Convert JobIndexSortByEnum type from Enum to Literal
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Mar 14, 2023
1 parent ca170b6 commit 3a0aa25
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
8 changes: 1 addition & 7 deletions client/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4852,12 +4852,6 @@ export interface components {
*/
update_time: string;
};
/**
* JobIndexSortByEnum
* @description An enumeration.
* @enum {string}
*/
JobIndexSortByEnum: "create_time" | "update_time";
/**
* JobIndexViewEnum
* @description An enumeration.
Expand Down Expand Up @@ -12024,7 +12018,7 @@ export interface operations {
history_id?: string;
workflow_id?: string;
invocation_id?: string;
order_by?: components["schemas"]["JobIndexSortByEnum"];
order_by?: "create_time" | "update_time";
search?: string;
limit?: number;
offset?: number;
Expand Down
7 changes: 2 additions & 5 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
text_column_filter,
)
from galaxy.model.scoped_session import galaxy_scoped_session
from galaxy.schema.schema import (
JobIndexQueryPayload,
JobIndexSortByEnum,
)
from galaxy.schema.schema import JobIndexQueryPayload
from galaxy.security.idencoding import IdEncodingHelper
from galaxy.structured_app import StructuredApp
from galaxy.util import (
Expand Down Expand Up @@ -200,7 +197,7 @@ def build_and_apply_filters(query, objects, filter_func):
columns.append(model.Job.job_runner_name)
query = query.filter(raw_text_column_filter(columns, term))

if payload.order_by == JobIndexSortByEnum.create_time:
if payload.order_by == "create_time":
order_by = model.Job.create_time.desc()
else:
order_by = model.Job.update_time.desc()
Expand Down
6 changes: 2 additions & 4 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,9 +1106,7 @@ class WorkflowIndexQueryPayload(Model):
skip_step_counts: bool = False


class JobIndexSortByEnum(str, Enum):
create_time = "create_time"
update_time = "update_time"
JobIndexSortByEnum = Literal["create_time", "update_time"]


class JobIndexQueryPayload(Model):
Expand All @@ -1122,7 +1120,7 @@ class JobIndexQueryPayload(Model):
history_id: Optional[DecodedDatabaseIdField] = None
workflow_id: Optional[DecodedDatabaseIdField] = None
invocation_id: Optional[DecodedDatabaseIdField] = None
order_by: JobIndexSortByEnum = JobIndexSortByEnum.update_time
order_by: JobIndexSortByEnum = "update_time"
search: Optional[str] = None
limit: int = 500
offset: int = 0
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
)

SortByQueryParam: JobIndexSortByEnum = Query(
default=JobIndexSortByEnum.update_time,
default="update_time",
title="Sort By",
description="Sort results by specified field.",
)
Expand Down

0 comments on commit 3a0aa25

Please sign in to comment.