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

Changes to cache assessments #2093

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 14 additions & 8 deletions backend/src/components/cache-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions backend/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 2 additions & 0 deletions backend/src/schedulers/cache-service-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
});
});
},
Expand Down
Loading