Skip to content

Commit bb6dff5

Browse files
authored
Merge pull request #603 from topcoder-platform/dev
fix: cached templates
2 parents 970910b + 585c6fd commit bb6dff5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ workflows:
8383
branches:
8484
only:
8585
- dev
86+
- fix/template
8687

8788
- "build-qa":
8889
context: org-global

src/common/phase-helper.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ChallengePhaseHelper {
2525
throw new errors.BadRequestError(`Invalid timeline template ID: ${timelineTemplateId}`);
2626
}
2727
const { timelineTempate } = await this.getTemplateAndTemplateMap(timelineTemplateId);
28+
console.log("Selected timeline template", JSON.stringify(timelineTempate));
2829
const { phaseDefinitionMap } = await this.getPhaseDefinitionsAndMap();
2930
let fixedStartDate = undefined;
3031
const finalPhases = _.map(timelineTempate, (phaseFromTemplate) => {
@@ -202,17 +203,19 @@ class ChallengePhaseHelper {
202203
}
203204

204205
async getTemplateAndTemplateMap(timelineTemplateId) {
205-
if (_.isEmpty(this.timelineTemplateMap)) {
206+
if (_.isEmpty(this.timelineTemplateMap[timelineTemplateId])) {
206207
const records = await timelineTemplateService.getTimelineTemplate(timelineTemplateId);
207-
208208
const map = new Map();
209209
_.each(records.phases, (r) => {
210210
map.set(r.phaseId, r);
211211
});
212212

213-
this.timelineTemplateMap = { timelineTempate: records.phases, timelineTemplateMap: map };
213+
this.timelineTemplateMap[timelineTemplateId] = {
214+
timelineTempate: records.phases,
215+
timelineTemplateMap: map,
216+
};
214217
}
215-
return this.timelineTemplateMap;
218+
return this.timelineTemplateMap[timelineTemplateId];
216219
}
217220
}
218221

0 commit comments

Comments
 (0)