Skip to content

Feat 318 bulk creation error - #319

Open
karimouf wants to merge 3 commits into
devfrom
feat-318-bulk-creation-error
Open

Feat 318 bulk creation error#319
karimouf wants to merge 3 commits into
devfrom
feat-318-bulk-creation-error

Conversation

@karimouf

@karimouf karimouf commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Overview

This PR fixes two frontend issues:

  1. Error toasts disappeared after 5s — not enough time to read longer messages, forcing users to resubmit just to re-read the error
  2. Bulk assignment creation threw Assignment with ID X not found and left the modal open (even though the assignment was created successfully server-side), because the CSV-export step referenced documentsTable, submissionsTable, and reviewer — none of which exist on AssignmentModal.vue

Improvements

  • Error toasts now display for 10 seconds instead of 5, giving users enough time to read longer error messages without resubmitting

Bug fixes

  • Fixed: bulk assignment creation getting stuck with the modal open and a console error after a successful create — the CSV-export step referenced non-existent component properties (documentsTable, submissionsTable, reviewer), which broke the lookup and prevented onSuccess() (modal close + success toast) from running. Now uses the component's actual state (assignmentModalValue, selectedReviewer)
  • Removed: the assignmentType === 'document' ? ... : ... branch used to pick which table to search — the list being searched (assignmentModalValue) already only contains items of the currently active assignment type, making the branch redundant. It was also wrong for the study_session type, which incorrectly fell into the submission branch
    snippet of old create bulk assignment function:
this.$socket.emit("assignmentCreateBulk", socketData, (res) => {
        this.$refs.assignmentStepper.stopProgress();
        if (res.success) {
          if (this.reviewerSelectionMode.mode === 'role') {

            const filename = "assignments";
            const returnData = Object.keys(res.data).map((assignmentId) => {
              let assignment = null;
              if (this.assignmentType === 'document') {
                assignment = this.documentsTable.find((document) => document.id === Number(assignmentId));
              } else {
                assignment = this.submissionsTable.find((submission) => submission.id === Number(assignmentId));
              }
              if (!assignment) {
                console.error(`Assignment with ID ${assignmentId} not found.`);
                return null;
              }

              const assignmentUser = this.reviewer.find((reviewer) => reviewer.id === assignment.userId);
              const reviewer = res.data[assignmentId];

              const csv = {
                "assignedToName": assignmentUser.firstName + " " + assignmentUser.lastName,
                "assignedToFirstName": assignmentUser.firstName,
                "assignedToLastName": assignmentUser.lastName,
              }

              reviewer.forEach((reviewerId, index) => {
                const reviewerUser = this.reviewer.find((reviewer) => reviewer.id === Number(reviewerId));
                csv[`reviewer_${index + 1}`] = reviewerUser.firstName + " " + reviewerUser.lastName;
              });

              return csv;
            });

            downloadObjectsAs(returnData, filename, "csv");
          }
          this.$refs.assignmentStepper.close();
          this.eventBus.emit("toast", {
            title: "Assignment created",
            message: "The assignment has been created successfully",
            variant: "success",
          });
        } else {
          this.eventBus.emit("toast", {
            title: "Failed to create assignment",
            message: res.message,
            variant: "danger",
          });
        }
      })
    }

@bingobongomann
bingobongomann self-requested a review August 3, 2026 09:03
@bingobongomann
bingobongomann self-requested a review August 6, 2026 10:28

@bingobongomann bingobongomann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it on the full eiwa data assign 7500 sessions in around 2500 studies. It took almost 10min to finish but ran without any issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants