Skip to content

Commit 878f2da

Browse files
committed
Remove default pagination on v2 endpoints
If the user doesn't set pagination info, then retrieve all the information without pagination Signed-off-by: Gloria Ciavarrini <[email protected]>
1 parent 56584b0 commit 878f2da

File tree

7 files changed

+32
-43
lines changed

7 files changed

+32
-43
lines changed

plugins/orchestrator-backend/src/pagination.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ describe('buildPagination()', () => {
66
query: {},
77
};
88
expect(buildPagination(mockRequest)).toEqual({
9-
limit: 10,
10-
offset: 0,
11-
order: 'ASC',
9+
limit: undefined,
10+
offset: undefined,
11+
order: undefined,
1212
sortField: undefined,
1313
});
1414
});
@@ -19,9 +19,9 @@ describe('buildPagination()', () => {
1919
},
2020
};
2121
expect(buildPagination(mockRequest)).toEqual({
22-
limit: 10,
23-
offset: 0,
24-
order: 'ASC',
22+
limit: undefined,
23+
offset: undefined,
24+
order: undefined,
2525
sortField: 'lastUpdated',
2626
});
2727
});
@@ -49,9 +49,9 @@ describe('buildPagination()', () => {
4949
},
5050
};
5151
expect(buildPagination(mockRequest)).toEqual({
52-
limit: 10,
53-
offset: 0,
54-
order: 'ASC',
52+
limit: undefined,
53+
offset: undefined,
54+
order: undefined,
5555
sortField: undefined,
5656
});
5757
});

plugins/orchestrator-backend/src/service/api/v2.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ describe('getWorkflowOverview', () => {
119119
mapToWorkflowOverviewDTO(item),
120120
),
121121
paginationInfo: {
122-
page: 0,
123-
pageSize: 10,
122+
page: undefined,
123+
pageSize: undefined,
124124
totalCount: mockOverviewsV1.items.length,
125125
},
126126
});
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
export const WORKFLOW_DATA_KEY = 'workflowdata';
22

33
export const INTERNAL_SERVER_ERROR_MESSAGE = 'internal server error';
4-
export const DEFAULT_PAGE_NUMBER = 0;
5-
export const DEFAULT_PAGE_SIZE = 10;
6-
export const DEFAULT_SORT_FIELD = undefined;
7-
export const DEFAULT_SORT_ORDER = 'ASC';
84
export const FETCH_PROCESS_INSTANCES_SORT_FIELD = 'start';
Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import { Request } from 'express-serve-static-core';
22

3-
import {
4-
DEFAULT_PAGE_NUMBER,
5-
DEFAULT_PAGE_SIZE,
6-
DEFAULT_SORT_FIELD,
7-
DEFAULT_SORT_ORDER,
8-
} from '../service/constants';
9-
103
export interface Pagination {
114
offset?: number;
125
limit?: number;
@@ -15,18 +8,23 @@ export interface Pagination {
158
}
169

1710
export function buildPagination(req: Request): Pagination {
18-
return {
19-
offset: isNaN(req.query.page as any)
20-
? DEFAULT_PAGE_NUMBER
21-
: Number(req.query.page),
22-
limit: isNaN(req.query.pageSize as any)
23-
? DEFAULT_PAGE_SIZE
24-
: Number(req.query.pageSize),
25-
sortField: req.query.orderBy
26-
? String(req.query.orderBy)
27-
: DEFAULT_SORT_FIELD,
28-
order: req.query.orderDirection
29-
? String(req.query.orderDirection)
30-
: DEFAULT_SORT_ORDER,
31-
};
11+
const pagination: Pagination = {};
12+
13+
if (!isNaN(Number(req.query.page))) {
14+
pagination.offset = Number(req.query.page);
15+
}
16+
17+
if (!isNaN(Number(req.query.pageSize))) {
18+
pagination.limit = Number(req.query.pageSize);
19+
}
20+
21+
if (req.query.orderBy) {
22+
pagination.sortField = String(req.query.orderBy);
23+
}
24+
25+
if (req.query.orderDirection) {
26+
pagination.order = String(req.query.orderDirection);
27+
}
28+
29+
return pagination;
3230
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a6f1ec3718385945b49150694189881ac506b364
1+
af8bd8d631e1bde0b2776e64aae8adbc2bc332ce

plugins/orchestrator-common/src/generated/api/definition.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

plugins/orchestrator-common/src/openapi/openapi.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,21 +330,16 @@ components:
330330
properties:
331331
pageSize:
332332
type: number
333-
minimum: 10
334333
page:
335334
type: number
336-
default: 0
337335
totalCount:
338336
type: number
339-
minimum: 0
340337
orderDirection:
341338
enum:
342339
- ASC
343340
- DESC
344-
default: ASC
345341
orderBy:
346342
type: string
347-
minimum: 0
348343
additionalProperties: false
349344
WorkflowFormatDTO:
350345
type: string

0 commit comments

Comments
 (0)