From 0c047a25cedb6f8919b8004bce84ac101fe791b5 Mon Sep 17 00:00:00 2001 From: "QSL\\SumathiT" Date: Thu, 7 Nov 2024 11:22:12 -0800 Subject: [PATCH] Changes to cache assessmenttypecode. --- backend/src/components/cache-service.js | 22 ++++++++++++------- backend/src/config/index.js | 5 +++-- .../src/schedulers/cache-service-scheduler.js | 2 ++ .../StudentRegistrationsFilter.vue | 6 ++++- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/backend/src/components/cache-service.js b/backend/src/components/cache-service.js index cdd9882d6..45da23566 100644 --- a/backend/src/components/cache-service.js +++ b/backend/src/components/cache-service.js @@ -237,10 +237,13 @@ const cacheService = { async loadAllAssessmentTypeCodesToMap() { log.debug('Loading all assessment Type Codes during start up'); await retry(async () => { - const assessmentTypeCodesResponse = await getData(config.get('server:eas:assessmentTypeCodeURL')); - assessmentTypeCodesResponse.forEach(entry => { - assessmentTypeCodesMap.set(entry.assessmentTypeCode, entry.label); - }); + const assessmentTypeCodesResponse = await getData(config.get('server:eas:assessmentTypeCodeURL')); + if (assessmentTypeCodesResponse && assessmentTypeCodesResponse.length > 0) { + assessmentTypeCodesMap.clear(); // reset the value. + assessmentTypeCodesResponse.forEach(entry => { + assessmentTypeCodesMap.set(entry.assessmentTypeCode, entry.label); + }); + } log.info(`Loaded ${assessmentTypeCodesMap.size} assessmentTypeCodes.`); }, { retries: 50 @@ -250,10 +253,13 @@ const cacheService = { async loadAllSpecialCaseTypeCodesToMap() { log.debug('Loading all specialcase Type Codes during start up'); await retry(async () => { - const provincialSpecialCaseTypeCodesResponse = await getData(config.get('server:eas:assessmentSpecialCaseTypeCodeURL')); - provincialSpecialCaseTypeCodesResponse.forEach(entry => { - assessmentSpecialCaseTypeCodesMap.set(entry.provincialSpecialCaseCode, entry.label); - }); + const provincialSpecialCaseTypeCodesResponse = await getData(config.get('server:eas:assessmentSpecialCaseTypeCodeURL')); + if (provincialSpecialCaseTypeCodesResponse && provincialSpecialCaseTypeCodesResponse.length > 0) { + assessmentSpecialCaseTypeCodesMap.clear(); // reset the value. + provincialSpecialCaseTypeCodesResponse.forEach(entry => { + assessmentSpecialCaseTypeCodesMap.set(entry.provincialSpecialCaseCode, entry.label); + }); + } log.info(`Loaded ${assessmentSpecialCaseTypeCodesMap.size} assessmentSpecialCaseTypeCodes.`); }, { retries: 50 diff --git a/backend/src/config/index.js b/backend/src/config/index.js index 4042f7da1..538179313 100644 --- a/backend/src/config/index.js +++ b/backend/src/config/index.js @@ -154,8 +154,9 @@ nconf.defaults({ eas:{ rootURL: process.env.EAS_API_URL, assessmentSessionsURL: process.env.EAS_API_URL+ '/sessions', - assessmentTypesURL: process.env.EAS_API_URL+ '/assessments', - assessmentStudentsURL: process.env.EAS_API_URL+ '/students', + assessmentTypeCodeURL: process.env.EAS_API_URL+ '/assessment-types', + assessmentSpecialCaseTypeCodeURL: process.env.EAS_API_URL+ '/assessment-specialcase-types', + assessmentStudentsURL: process.env.EAS_API_URL+ '/student', } }, oidc: { diff --git a/backend/src/schedulers/cache-service-scheduler.js b/backend/src/schedulers/cache-service-scheduler.js index 328f5018a..89b519f00 100644 --- a/backend/src/schedulers/cache-service-scheduler.js +++ b/backend/src/schedulers/cache-service-scheduler.js @@ -12,6 +12,8 @@ try { await cacheService.loadAllDocumentTypeCodesToMap(); await cacheService.loadAllDistrictsToMap(); await cacheService.loadAllAuthoritiesToMap(); + await cacheService.loadAllAssessmentTypeCodesToMap(); + await cacheService.loadAllSpecialCaseTypeCodesToMap(); } catch (e) { log.error(e); } diff --git a/frontend/src/components/assessments/registrations/StudentRegistrationsFilter.vue b/frontend/src/components/assessments/registrations/StudentRegistrationsFilter.vue index 6fff2904a..72c19de4e 100644 --- a/frontend/src/components/assessments/registrations/StudentRegistrationsFilter.vue +++ b/frontend/src/components/assessments/registrations/StudentRegistrationsFilter.vue @@ -332,10 +332,14 @@ export default { }, setupAssessmentSessions() { this.sessionSearchNames = []; + this.assessmentTypeSearchNames = []; this.schoolYearSessions.forEach(session => { this.sessionSearchNames.push({title: this.formatMonth(session.courseMonth), id: session.sessionID, value: session.sessionID}); session.assessments.forEach(assessment => { - this.assessmentTypeSearchNames.push({title: assessment.assessmentTypeName, id: assessment.assessmentTypeCode, value: assessment.assessmentTypeCode}); + let existingItem = this.assessmentTypeSearchNames.find(item => item.id === assessment.assessmentTypeCode); + if (!existingItem) { + this.assessmentTypeSearchNames.push({title: assessment.assessmentTypeName, id: assessment.assessmentTypeCode, value: assessment.assessmentTypeCode}); + } }); }); },