Skip to content

Commit

Permalink
added locale column in generated resource table for generating templa…
Browse files Browse the repository at this point in the history
…te based on locale (#1351)
  • Loading branch information
nitish-egov authored Jan 29, 2025
1 parent 343393e commit d94b380
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE eg_cm_generated_resource_details
ADD COLUMN locale VARCHAR(50);
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ const trimError = (e: any) => {
async function searchGeneratedResources(request: any) {
try {
const { type, tenantId, hierarchyType, id, status, campaignId } = request.query;
const msgIdRaw = request.body.RequestInfo?.msgId;
const locale = msgIdRaw?.split('|')[1] || null;
let queryString = `SELECT * FROM ${config?.DB_CONFIG.DB_GENERATED_RESOURCE_DETAILS_TABLE_NAME} WHERE `;
let queryConditions: string[] = [];
let queryValues: any[] = [];
Expand Down Expand Up @@ -257,6 +259,10 @@ async function searchGeneratedResources(request: any) {
queryConditions.push(`(${statusConditions.join(' OR ')})`);
queryValues.push(...statusArray);
}
if (locale) {
queryConditions.push(`locale = $${queryValues.length + 1}`);
queryValues.push(locale);
}

queryString += queryConditions.join(" AND ");

Expand Down Expand Up @@ -307,7 +313,8 @@ async function generateNewRequestObject(request: any) {
},
additionalDetails: additionalDetails,
count: null,
campaignId: request?.query?.campaignId
campaignId: request?.query?.campaignId,
locale: request?.body?.RequestInfo?.msgId?.split('|')[1] || null
};
return [newEntry];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const generatedResourceTransformer = (dbRows: any[] = []) => {
item.additionalDetails = item.additionaldetails;
item.additionalDetails.Filters = item?.additionaldetails?.filters ? {} : item?.additionaldetails?.filters;
item.fileStoreid = item.filestoreid;
item.locale = item.locale;

// Remove unnecessary properties
delete item.additionaldetails;
Expand Down

0 comments on commit d94b380

Please sign in to comment.