Skip to content

Commit

Permalink
FIX: Remove pre-allocation of run ID
Browse files Browse the repository at this point in the history
  • Loading branch information
richford committed Mar 4, 2024
1 parent afcb49f commit 0d1f9b1
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/firestore/firekit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -898,23 +898,14 @@ export class RoarFirekit {
throw new Error(`Could not find assessment with taskId ${taskId} in administration ${administrationId}`);
}

// Create the run in the assessment Firestore, record the runId and then
// pass it to the app
const runRef = doc(this.dbRefs!.app.runs);
const runId = runRef.id;

// Check the assignment to see if none of the assessments have been
// started yet. If not, start the assignment
const assignmentDocRef = doc(this.dbRefs!.admin.assignments, administrationId);
const assignmentDocSnap = await transaction.get(assignmentDocRef);
if (assignmentDocSnap.exists()) {
const assignedAssessments = assignmentDocSnap.data().assessments as IAssignedAssessmentData[];
const allRunIdsForThisTask = assignedAssessments.find((a) => a.taskId === taskId)?.allRunIds || [];
allRunIdsForThisTask.push(runId);

const assessmentUpdateData: { startedOn: Date; allRunIds: string[]; runId?: string } = {
const assessmentUpdateData = {
startedOn: new Date(),
allRunIds: allRunIdsForThisTask,
};

// Append runId to `allRunIds` for this assessment
Expand Down Expand Up @@ -967,7 +958,6 @@ export class RoarFirekit {
assigningOrgs,
readOrgs,
assignmentId: administrationId,
runId,
taskInfo,
});
} else {
Expand Down

0 comments on commit 0d1f9b1

Please sign in to comment.