-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SIMSBIOHUB-483: Paginate the Projects lists endpoint (#1212)
* Added new environment variables used to the set number of seed projects and surveys to generate: NUM_SEED_PROJECTS and NUM_SEED_SURVEYS_PER_PROJECT. * Removed frontend code associated with creating, editing and deleting project drafts. * Optimized SQL queries used to fetch the projects list * Removed the project submission status from the projects list response * Removed the project submission status banner * Modified the list projects endpoint to support server-side pagination
- Loading branch information
1 parent
d306ce3
commit 493e17b
Showing
34 changed files
with
714 additions
and
1,003 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { SchemaObject } from 'ajv'; | ||
|
||
/** | ||
* API schema used to assert pagination query paramaters | ||
* for paginated data requests. | ||
*/ | ||
export const paginationRequestQueryParamSchema: any[] = [ | ||
{ | ||
in: 'query', | ||
name: 'page', | ||
required: false, | ||
schema: { | ||
type: 'integer', | ||
minimum: 1, | ||
description: 'The current page number to be fetched' | ||
} | ||
}, | ||
{ | ||
in: 'query', | ||
name: 'limit', | ||
required: false, | ||
schema: { | ||
type: 'integer', | ||
minimum: 1, | ||
maximum: 100, | ||
description: 'The number of records to show per page' | ||
} | ||
}, | ||
{ | ||
in: 'query', | ||
name: 'sort', | ||
required: false, | ||
description: `The column to be sorted on, e.g. 'name'`, | ||
schema: { | ||
type: 'string' | ||
} | ||
}, | ||
{ | ||
in: 'query', | ||
name: 'order', | ||
required: false, | ||
description: 'The order of the sort, i.e. asc or desc', | ||
schema: { | ||
type: 'string', | ||
enum: ['asc', 'desc'] | ||
} | ||
} | ||
]; | ||
|
||
/** | ||
* API schema to assert pagination information for paginated data | ||
* responses. | ||
*/ | ||
export const paginationResponseSchema: SchemaObject = { | ||
type: 'object', | ||
required: ['total', 'current_page', 'last_page'], | ||
properties: { | ||
total: { | ||
type: 'integer', | ||
description: 'The total number of records belonging to the collection' | ||
}, | ||
per_page: { | ||
type: 'integer', | ||
minimum: 1, | ||
description: 'The number of records shown per page' | ||
}, | ||
current_page: { | ||
type: 'integer', | ||
description: 'The current page being fetched' | ||
}, | ||
last_page: { | ||
type: 'integer', | ||
minimum: 1, | ||
description: 'The total number of pages' | ||
}, | ||
sort: { | ||
type: 'string', | ||
description: 'The column that is being sorted on' | ||
}, | ||
order: { | ||
type: 'string', | ||
enum: ['asc', 'desc'], | ||
description: 'The sort order of the response' | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.