Skip to content

fix: cached templates #603

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

Merged
merged 4 commits into from
Mar 28, 2023
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ workflows:
branches:
only:
- dev
- fix/template

- "build-qa":
context: org-global
Expand Down
11 changes: 7 additions & 4 deletions src/common/phase-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ChallengePhaseHelper {
throw new errors.BadRequestError(`Invalid timeline template ID: ${timelineTemplateId}`);
}
const { timelineTempate } = await this.getTemplateAndTemplateMap(timelineTemplateId);
console.log("Selected timeline template", JSON.stringify(timelineTempate));
const { phaseDefinitionMap } = await this.getPhaseDefinitionsAndMap();
let fixedStartDate = undefined;
const finalPhases = _.map(timelineTempate, (phaseFromTemplate) => {
Expand Down Expand Up @@ -202,17 +203,19 @@ class ChallengePhaseHelper {
}

async getTemplateAndTemplateMap(timelineTemplateId) {
if (_.isEmpty(this.timelineTemplateMap)) {
if (_.isEmpty(this.timelineTemplateMap[timelineTemplateId])) {
const records = await timelineTemplateService.getTimelineTemplate(timelineTemplateId);

const map = new Map();
_.each(records.phases, (r) => {
map.set(r.phaseId, r);
});

this.timelineTemplateMap = { timelineTempate: records.phases, timelineTemplateMap: map };
this.timelineTemplateMap[timelineTemplateId] = {
timelineTempate: records.phases,
timelineTemplateMap: map,
};
}
return this.timelineTemplateMap;
return this.timelineTemplateMap[timelineTemplateId];
}
}

Expand Down