Skip to content

Commit

Permalink
Merge pull request #83 from yeatmanlab/enh/add-reliable-by-block
Browse files Browse the repository at this point in the history
update addEngagementByBlock method to store reliableByBlock attribute for block-scoped assessments
  • Loading branch information
richford authored Jan 30, 2024
2 parents 663fc88 + 0e7675f commit 450774a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/firestore/app/appkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ export class RoarAppkit {
* Please note that calling this function with a new set of engagement flags will
* overwrite the previous set.
*/
async updateEngagementFlags(flagNames: string[], markAsReliable = false) {
async updateEngagementFlags(flagNames: string[], markAsReliable = false, reliableByBlock = undefined) {
if (this._started) {
return this.run!.addEngagementFlags(flagNames, markAsReliable);
return this.run!.addEngagementFlags(flagNames, markAsReliable, reliableByBlock);
} else {
throw new Error('This run has not started. Use the startRun method first.');
}
Expand Down
15 changes: 13 additions & 2 deletions src/firestore/app/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,14 @@ export class RoarRun {
* @async
* @param {string[]} engagementFlags - Engagement flags to add to the run
* @param {boolean} markAsReliable - Whether or not to mark the run as reliable, defaults to false
* @param {Object} reliableByBlock - Stores the reliability of the run by block
* This is an optional parameter that needs only to be passed in for block scoped tasks
* For Example: {DEL: false, FSM: true, LSM: false}
*
* Please note that calling this function with a new set of engagement flags will
* overwrite the previous set.
*/
async addEngagementFlags(engagementFlags: string[], markAsReliable = false) {
async addEngagementFlags(engagementFlags: string[], markAsReliable = false, reliableByBlock = undefined) {
if (!this.started) {
throw new Error('Run has not been started yet. Use the startRun method first.');
}
Expand All @@ -231,12 +234,20 @@ export class RoarRun {
}, {});

if (!this.aborted) {
return updateDoc(this.runRef, { engagementFlags: engagementObj, reliable: markAsReliable });
// In cases that the run is non-block-scoped and should only have the reliable attribute stored
if (reliableByBlock === undefined) {
return updateDoc(this.runRef, { engagementFlags: engagementObj, reliable: markAsReliable });
}
// In cases we want to store reliability by block, we need to store the reliable attribute as well as the reliableByBlock attribute
else {
return updateDoc(this.runRef, { engagementFlags: engagementObj, reliable: markAsReliable, reliableByBlock: reliableByBlock });
}
} else {
throw new Error('Run has already been aborted.');
}
}


/**
* Mark this run as complete on Firestore
* @method
Expand Down

0 comments on commit 450774a

Please sign in to comment.