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

updated workflow list to sort by name #332

Merged
merged 6 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
22 changes: 21 additions & 1 deletion src/schema/api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,14 @@ type Query {
uniconfigShellSession: String
workflowInstanceDetail(shouldIncludeTasks: Boolean, workflowId: String!): WorkflowInstanceDetail
workflowLabels: [String!]!
workflows(after: String, before: String, filter: FilterWorkflowsInput, first: Int, last: Int): WorkflowConnection!
workflows(
after: String
before: String
filter: FilterWorkflowsInput
first: Int
last: Int
orderBy: WorkflowsOrderByInput!
): WorkflowConnection!
zones(after: String, before: String, first: Int, last: Int): ZonesConnection!
}

Expand Down Expand Up @@ -1048,6 +1055,14 @@ enum SortDirection {
DESC
}

enum SortWorkflowsBy {
name
}

enum SortWorkflowsDirection {
asc
desc
}
enum SortExecutedWorkflowsBy {
endTime
startTime
Expand Down Expand Up @@ -1360,6 +1375,11 @@ enum WorkflowTaskType {
WAIT
}

input WorkflowsOrderByInput {
direction: SortWorkflowsDirection!
sortKey: SortWorkflowsBy!
}

type Zone implements Node {
createdAt: String!
id: ID!
Expand Down
8 changes: 8 additions & 0 deletions src/schema/nexus-typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ export interface NexusGenInputs {
updatedAt?: string | null; // String
version?: number | null; // Int
};
WorkflowsOrderByInput: {
// input type
direction: NexusGenEnums['SortWorkflowsDirection']; // SortWorkflowsDirection!
sortKey: NexusGenEnums['SortWorkflowsBy']; // SortWorkflowsBy!
};
}

export interface NexusGenEnums {
Expand All @@ -456,6 +461,8 @@ export interface NexusGenEnums {
ScheduleStatus: 'COMPLETED' | 'FAILED' | 'PAUSED' | 'RUNNING' | 'TERMINATED' | 'TIMED_OUT' | 'UNKNOWN';
SortDeviceBy: 'CREATED_AT' | 'NAME';
SortDirection: 'ASC' | 'DESC';
SortWorkflowsBy: 'name';
SortWorkflowsDirection: 'asc' | 'desc';
SortExecutedWorkflowsBy: 'endTime' | 'startTime' | 'status' | 'workflowId' | 'workflowName';
SortExecutedWorkflowsDirection: 'asc' | 'desc';
SortPollsBy: 'lastPollTime' | 'queueName' | 'workerId';
Expand Down Expand Up @@ -2931,6 +2938,7 @@ export interface NexusGenArgTypes {
filter?: NexusGenInputs['FilterWorkflowsInput'] | null; // FilterWorkflowsInput
first?: number | null; // Int
last?: number | null; // Int
orderBy: NexusGenInputs['WorkflowsOrderByInput']; // WorkflowsOrderByInput!
};
zones: {
// args
Expand Down
25 changes: 23 additions & 2 deletions src/schema/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ export const FilterWorkflowsInput = inputObjectType({
},
});

export const SortWorkflowsBy = enumType({
name: 'SortWorkflowsBy',
members: ['name'],
});

export const SortWorkflowsDirection = enumType({
name: 'SortWorkflowsDirection',
members: ['asc', 'desc'],
});

export const WorkflowsOrderByInput = inputObjectType({
name: 'WorkflowsOrderByInput',
definition: (t) => {
t.nonNull.field('sortKey', { type: SortWorkflowsBy });
t.nonNull.field('direction', { type: SortWorkflowsDirection });
},
});

export const WorkflowsQuery = extendType({
type: 'Query',
definition: (t) => {
Expand All @@ -154,15 +172,18 @@ export const WorkflowsQuery = extendType({
args: {
...PaginationConnectionArgs,
filter: FilterWorkflowsInput,
orderBy: nonNull(WorkflowsOrderByInput),
},
resolve: async (_, args, { conductorAPI }) => {
const { filter, ...paginationArgs } = args;
const { filter, orderBy: orderingArgs, ...paginationArgs } = args;
const workflows = await conductorAPI.getWorkflowMetadata(config.conductorApiURL);

const filteredWorkflows =
filter?.labels || filter?.keyword ? getFilteredWorkflows(workflows, filter) : workflows;

const workflowsWithId = filteredWorkflows.map((w) => ({
const orderedData = orderBy(filteredWorkflows, [orderingArgs.sortKey], [orderingArgs.direction]);

const workflowsWithId = orderedData.map((w) => ({
...w,
id: w.name,
}));
Expand Down