Skip to content

fix(orchestrator): remove default pagination on v2 endpoints #1983

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

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 9 additions & 9 deletions plugins/orchestrator-backend/src/pagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ describe('buildPagination()', () => {
query: {},
};
expect(buildPagination(mockRequest)).toEqual({
limit: 10,
offset: 0,
order: 'ASC',
limit: undefined,
offset: undefined,
order: undefined,
sortField: undefined,
});
});
Expand All @@ -19,9 +19,9 @@ describe('buildPagination()', () => {
},
};
expect(buildPagination(mockRequest)).toEqual({
limit: 10,
offset: 0,
order: 'ASC',
limit: undefined,
offset: undefined,
order: undefined,
sortField: 'lastUpdated',
});
});
Expand Down Expand Up @@ -49,9 +49,9 @@ describe('buildPagination()', () => {
},
};
expect(buildPagination(mockRequest)).toEqual({
limit: 10,
offset: 0,
order: 'ASC',
limit: undefined,
offset: undefined,
order: undefined,
sortField: undefined,
});
});
Expand Down
4 changes: 2 additions & 2 deletions plugins/orchestrator-backend/src/service/api/v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ describe('getWorkflowOverview', () => {
mapToWorkflowOverviewDTO(item),
),
paginationInfo: {
page: 0,
pageSize: 10,
page: undefined,
pageSize: undefined,
totalCount: mockOverviewsV1.items.length,
},
});
Expand Down
4 changes: 0 additions & 4 deletions plugins/orchestrator-backend/src/service/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export const WORKFLOW_DATA_KEY = 'workflowdata';

export const INTERNAL_SERVER_ERROR_MESSAGE = 'internal server error';
export const DEFAULT_PAGE_NUMBER = 0;
export const DEFAULT_PAGE_SIZE = 10;
export const DEFAULT_SORT_FIELD = undefined;
export const DEFAULT_SORT_ORDER = 'ASC';
export const FETCH_PROCESS_INSTANCES_SORT_FIELD = 'start';
40 changes: 19 additions & 21 deletions plugins/orchestrator-backend/src/types/pagination.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { Request } from 'express-serve-static-core';

import {
DEFAULT_PAGE_NUMBER,
DEFAULT_PAGE_SIZE,
DEFAULT_SORT_FIELD,
DEFAULT_SORT_ORDER,
} from '../service/constants';

export interface Pagination {
offset?: number;
limit?: number;
Expand All @@ -15,18 +8,23 @@ export interface Pagination {
}

export function buildPagination(req: Request): Pagination {
return {
offset: isNaN(req.query.page as any)
? DEFAULT_PAGE_NUMBER
: Number(req.query.page),
limit: isNaN(req.query.pageSize as any)
? DEFAULT_PAGE_SIZE
: Number(req.query.pageSize),
sortField: req.query.orderBy
? String(req.query.orderBy)
: DEFAULT_SORT_FIELD,
order: req.query.orderDirection
? String(req.query.orderDirection)
: DEFAULT_SORT_ORDER,
};
const pagination: Pagination = {};

if (!isNaN(Number(req.query.page))) {
pagination.offset = Number(req.query.page);
}

if (!isNaN(Number(req.query.pageSize))) {
pagination.limit = Number(req.query.pageSize);
}

if (req.query.orderBy) {
pagination.sortField = String(req.query.orderBy);
}

if (req.query.orderDirection) {
pagination.order = String(req.query.orderDirection);
}

return pagination;
}
2 changes: 1 addition & 1 deletion plugins/orchestrator-common/src/generated/.METADATA.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a6f1ec3718385945b49150694189881ac506b364
af8bd8d631e1bde0b2776e64aae8adbc2bc332ce

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions plugins/orchestrator-common/src/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,21 +330,16 @@ components:
properties:
pageSize:
type: number
minimum: 10
page:
type: number
default: 0
totalCount:
type: number
minimum: 0
orderDirection:
enum:
- ASC
- DESC
default: ASC
orderBy:
type: string
minimum: 0
additionalProperties: false
WorkflowFormatDTO:
type: string
Expand Down