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

Read,list,delete query template #149

Merged
merged 17 commits into from
Apr 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4f4037a
Sanketika-obsrv/issue-tracker#74: added read template api implementat…
yashashkumar Apr 29, 2024
f92d3e9
Sanketika-obsrv/issue-tracker#74: removed msgid
yashashkumar Apr 29, 2024
9296100
Sanketika-obsrv/issue-tracker#74: removed msgid
yashashkumar Apr 29, 2024
d1516fa
Sanketika-obsrv/issue-tracker#74: controller for list templates api w…
yashashkumar Apr 29, 2024
fbf5737
Sanketika-obsrv/issue-tracker#74: controller for delete template api …
yashashkumar Apr 29, 2024
97fe4a5
Sanketika-obsrv/issue-tracker#74: added template id in loggers
yashashkumar Apr 29, 2024
e420bf0
Sanketika-obsrv/issue-tracker#74: added template id in loggers
yashashkumar Apr 29, 2024
3630ef3
Sanketika-obsrv/issue-tracker#74: variable name changes
yashashkumar Apr 29, 2024
536f003
Sanketika-obsrv/issue-tracker#74: changed variable name
yashashkumar Apr 29, 2024
c22c587
Sanketika-obsrv/issue-tracker#74: added prefix for each api id and ad…
yashashkumar Apr 29, 2024
bfb1b4b
Sanketika-obsrv/issue-tracker#74: added loggers
yashashkumar Apr 29, 2024
765a698
Sanketika-obsrv/issue-tracker#74: updated schema
yashashkumar Apr 29, 2024
a5e105c
Sanketika-obsrv/issue-tracker#74: added filters for list api (sortBy,…
yashashkumar Apr 30, 2024
05b0a49
Sanketika-obsrv/issue-tracker#74: added filters for list api (sortBy,…
yashashkumar Apr 30, 2024
105afeb
Sanketika-obsrv/issue-tracker#74: added sory to query and logging tem…
yashashkumar Apr 30, 2024
b1a4a8b
Sanketika-obsrv/issue-tracker#74: removed unused variable
yashashkumar Apr 30, 2024
f34f80c
Sanketika-obsrv/issue-tracker#74: removed max value for offset
yashashkumar Apr 30, 2024
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
Prev Previous commit
Next Next commit
Sanketika-Obsrv/issue-tracker#74: added sory to query and logging tem…
…plate read response
yashashkumar committed Apr 30, 2024
commit 105afebdea8e01ccad9f058036c90cb356fd84b4
Original file line number Diff line number Diff line change
@@ -41,38 +41,39 @@
},
"additionalProperties": false
},
"sortBy": {
"order": {
"type": "array",
"items": {
"type": "object",
"properties": {
"field": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": [
{
"type": "string",
"enum": [
"created_date",
"updated_date"
]
},
"order": {
{
"type": "string",
"enum": [
"asc",
"desc"
"ASC",
"DESC"
]
}
},
"additionalProperties": false,
"required": [
"field",
"order"
]
}
},
"limit": {
"type": "number"
"type": "number",
"minimum": 5,
"maximum": 500
},
"offset": {
"type": "number"
"type": "number",
"minimum": 0,
"maximum": 10
}
},
"additionalProperties": false
Original file line number Diff line number Diff line change
@@ -35,12 +35,8 @@
const getTemplateList = async (req: Record<string, any>) => {
const limit: any = _.get(req, "limit");
const offset: any = _.get(req, "offset");
const order: any = _.get(req, "order");
const { filters = {}, sortBy = [] } = req || {};

Check failure on line 39 in api-service/src/controllers/ListQueryTemplates/ListTemplatesController.ts

GitHub Actions / test-cases

'sortBy' is assigned a value but never used
const templates = await QueryTemplate.findAll({ limit: limit || 100, offset: offset || 0, ...(filters && { where: filters }) })
if (sortBy) {
const fieldValues = _.map(sortBy, field => _.get(field, "field"))
const orderValues = _.map(sortBy, field => _.get(field, "order"))
return _.orderBy(templates, fieldValues, orderValues)
}
const templates = await QueryTemplate.findAll({ limit: limit || 100, offset: offset || 0, order, ...(filters && { where: filters }) })
return templates
}
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ export const readQueryTemplate = async (req: Request, res: Response) => {
logger.error({ apiId, resmsgid, template_id, message: `Template ${template_id} does not exists`, code: "QUERY_TEMPLATE_NOT_EXISTS" })
return ResponseHandler.errorResponse({ message: `Template ${template_id} does not exists`, statusCode: 404, errCode: "NOT_FOUND", code: "QUERY_TEMPLATE_NOT_EXISTS" }, req, res);
}
logger.info({ apiId, resmsgid, template_id, message: `Template read successfully with id: ${template_id}` })
logger.info({ apiId, resmsgid, template_id, message: `Template read successfully with id: ${template_id}`, response: { status: 200, data: template?.dataValues } })
return ResponseHandler.successResponse(req, res, { status: 200, data: template?.dataValues });
}
catch (error) {