Skip to content

Commit

Permalink
Rename task to reference backlog
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Aug 22, 2024
1 parent b64f783 commit 002c82a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
// were previously held in a backlog due to submissions coming in out of order.

const { run } = require('../task/task');
const { processHeldSubmissions } = require('../task/process-held-submissions');
const { processBacklog } = require('../task/process-backlog');

const { program } = require('commander');
program.option('-f, --force', 'Force all submissions in the backlog to be processed immediately.');
program.parse();

const options = program.opts();

run(processHeldSubmissions(options.force)
run(processBacklog(options.force)
.then((count) => `Submissions processed: ${count}`));
4 changes: 2 additions & 2 deletions lib/model/query/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ const _getHeldSubmissionsAsEvents = (force) => ({ all }) => all(sql`
ORDER BY "branchId", "branchBaseVersion"`)
.then(map(construct(Audit)));

const processHeldSubmissions = (force = false) => async (container) => {
const processBacklog = (force = false) => async (container) => {
const events = await container.Entities._getHeldSubmissionsAsEvents(force);
return runSequentially(events.map(event =>
async () => {
Expand Down Expand Up @@ -714,7 +714,7 @@ module.exports = {
_computeBaseVersion,
_holdSubmission, _checkHeldSubmission,
_getNextHeldSubmissionInBranch, _deleteHeldSubmissionByEventId,
_getHeldSubmissionsAsEvents, processHeldSubmissions,
_getHeldSubmissionsAsEvents, processBacklog,
processSubmissionEvent, streamForExport,
getDefBySubmissionId,
createVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
// overladen and bogged down over time.

const { task } = require('./task');
const processHeldSubmissions = task.withContainer(({ Entities }) => Entities.processHeldSubmissions);
module.exports = { processHeldSubmissions };
const processBacklog = task.withContainer(({ Entities }) => Entities.processBacklog);
module.exports = { processBacklog };

14 changes: 7 additions & 7 deletions test/integration/api/offline-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ describe('Offline Entities', () => {
let backlogCount = await container.oneFirst(sql`select count(*) from entity_submission_backlog`);
backlogCount.should.equal(1);

await container.Entities.processHeldSubmissions(true);
await container.Entities.processBacklog(true);

await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc')
.expect(200)
Expand Down Expand Up @@ -846,7 +846,7 @@ describe('Offline Entities', () => {
let backlogCount = await container.oneFirst(sql`select count(*) from entity_submission_backlog`);
backlogCount.should.equal(2);

await container.Entities.processHeldSubmissions(true);
await container.Entities.processBacklog(true);

await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc')
.expect(200)
Expand Down Expand Up @@ -885,7 +885,7 @@ describe('Offline Entities', () => {
let backlogCount = await container.oneFirst(sql`select count(*) from entity_submission_backlog`);
backlogCount.should.equal(1);

await container.Entities.processHeldSubmissions(true);
await container.Entities.processBacklog(true);

await asAlice.get(`/v1/projects/1/datasets/people/entities/${newUuid}`)
.expect(200)
Expand Down Expand Up @@ -940,7 +940,7 @@ describe('Offline Entities', () => {
let backlogCount = await container.oneFirst(sql`select count(*) from entity_submission_backlog`);
backlogCount.should.equal(2);

await container.Entities.processHeldSubmissions(true);
await container.Entities.processBacklog(true);

await asAlice.get(`/v1/projects/1/datasets/people/entities/${newUuid}`)
.expect(200)
Expand Down Expand Up @@ -976,7 +976,7 @@ describe('Offline Entities', () => {
backlogCount = await container.oneFirst(sql`select count(*) from entity_submission_backlog`);
backlogCount.should.equal(1);

await container.Entities.processHeldSubmissions(true);
await container.Entities.processBacklog(true);

await asAlice.get(`/v1/projects/1/datasets/people/entities/${newUuid}`)
.expect(200)
Expand Down Expand Up @@ -1020,7 +1020,7 @@ describe('Offline Entities', () => {
backlogCount.should.equal(1);

// Force the update submission to be processed as a create
await container.Entities.processHeldSubmissions(true);
await container.Entities.processBacklog(true);

await asAlice.get(`/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789ddd`)
.expect(200)
Expand Down Expand Up @@ -1107,7 +1107,7 @@ describe('Offline Entities', () => {

// Process submissions that have been in the backlog for a long time
// (only 1 of 2 should be processed)
const count = await container.Entities.processHeldSubmissions();
const count = await container.Entities.processBacklog();
count.should.equal(1);

await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc')
Expand Down

0 comments on commit 002c82a

Please sign in to comment.