Skip to content

Commit

Permalink
add identifier to cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen committed Mar 21, 2024
1 parent f3e3927 commit d1674d3
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions portal/static/js/src/empro.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,16 @@ emproObj.prototype.init = function () {
return new Date(b.authored) - new Date(a.authored);
});
let assessmentDate = assessmentData[0]["authored"];
let [today, authoredDate, status] = [
let [today, authoredDate, status, identifier] = [
tnthDate.getDateWithTimeZone(new Date(), "yyyy-mm-dd"),
tnthDate.getDateWithTimeZone(
new Date(assessmentDate),
"yyyy-mm-dd"
),
assessmentData[0].status,
assessmentData[0].identifier && assessmentData[0].identifier.value
? assessmentData[0].identifier.value
: assessmentDate,
];
let assessmentCompleted =
String(status).toLowerCase() === "completed";
Expand All @@ -383,15 +386,17 @@ emproObj.prototype.init = function () {
"author date ",
authoredDate,
" assessment completed ",
assessmentCompleted
assessmentCompleted,
" identifier ",
identifier
);

this.authorDate = authoredDate;

/*
* associating each thank you modal popup accessed by assessment date
*/
let cachedAccessKey = `EMPRO_MODAL_ACCESSED_${this.userId}_${today}_${authoredDate}`;
let cachedAccessKey = `EMPRO_MODAL_ACCESSED_${this.userId}_${today}_${authoredDate}_${identifier}`;
this.cachedAccessKey = cachedAccessKey;

const clearCacheData = getUrlParameter("clearCache");
Expand Down Expand Up @@ -518,33 +523,37 @@ emproObj.prototype.initTriggerDomains = function (callbackFunc) {
}
//var self = this;
const isDebugging = getUrlParameter("debug");
tnthAjax.getSubStudyTriggers(this.userId, { maxTryAttempts: isDebugging ? 1 : 5 }, (data) => {
if (isDebugging) {
data = TestTriggersJson;
}
console.log("Trigger data: ", data);
if (!data || data.error || !data.triggers || !data.triggers.domain) {
callback({ error: true, reason: "no trigger data" });
return false;
}
tnthAjax.getSubStudyTriggers(
this.userId,
{ maxTryAttempts: isDebugging ? 1 : 5 },
(data) => {
if (isDebugging) {
data = TestTriggersJson;
}
console.log("Trigger data: ", data);
if (!data || data.error || !data.triggers || !data.triggers.domain) {
callback({ error: true, reason: "no trigger data" });
return false;
}

this.processTriggerData(data);
this.processTriggerData(data);

/*
* display user domain topic(s)
*/
this.populateDomainDisplay();
/*
* show/hide sections based on triggers
*/
this.initTriggerItemsVis();
/*
* display user domain topic(s)
*/
this.populateDomainDisplay();
/*
* show/hide sections based on triggers
*/
this.initTriggerItemsVis();

callback(data);
callback(data);

//console.log("self.domains? ", self.domains);
//console.log("has hard triggers ", self.hasHardTrigger);
//console.log("has soft triggers ", self.hasSoftTrigger);
});
//console.log("self.domains? ", self.domains);
//console.log("has hard triggers ", self.hasHardTrigger);
//console.log("has soft triggers ", self.hasSoftTrigger);
}
);
};
let EmproObj = new emproObj();
$(document).ready(function () {
Expand Down

0 comments on commit d1674d3

Please sign in to comment.