Skip to content

Conversation

@leoraba
Copy link
Contributor

@leoraba leoraba commented Jun 10, 2025

Summary

Fix issue where processing a submission with multiple files falls in a race condition where some data get lost.

Issues

Description of Changes

Data Provider Package

The Submission Service now handles batch processing of multiple files or entity datasets, updating submission data accordingly where each submission is updated in the database only once, and the entire dataset is validated a single time per submission.
Making this process in a batch based approach ensures consistency and helps to prevent race conditions.

Extras included:

  • Added Unit tests to new functions, to make sure response is as expected.
  • Splitting large files by relocating functions in separate files.

Readiness Checklist

  • Self Review
    • I have performed a self review of code
    • I have run the application locally and manually tested the feature
    • I have checked all updates to correct typos and misspellings
  • Formatting
    • Code follows the project style guide
    • Autmated code formatters (ie. Prettier) have been run
  • Local Testing
    • Successfully built all packages locally
    • Successfully ran all test suites, all unit and integration tests pass
  • Updated Tests
    • Unit and integration tests have been added that describe the bug that was fixed or the features that were added
  • Documentation
    • All new environment variables added to .env.schema file and documented in the README
    • All changes to server HTTP endpoints have open-api documentation
    • All new functions exported from their module have TSDoc comment documentation

}: {
records: Record<string, unknown>[];
entityName: string;
data: EntityData;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This submit method now accepts a data argument, which is a map of entity names to arrays of raw records to be processed in the submission. This ensures submission is processed and validated as a single batch.

Comment on lines +680 to +683
await update(activeSubmission.id, {
data: mergedSubmissionData,
updatedBy: username,
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When new data is added to the submission, it is merged with the existing data in the active submission and then persisted to the database. This ensures that the submission contains all data merged and complete before the the validation occurs afterward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just relocated these methods from a large files and regrouping related functions in smaller files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

relating functions into smaller files.

@leoraba
Copy link
Contributor Author

leoraba commented Jun 24, 2025

This PR has been split in smaller PRs:

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