Skip to content

Commit

Permalink
scripts(archive-ticket): Add option to block on or just queue job
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Balmos <[email protected]>
  • Loading branch information
abalmos committed Nov 21, 2024
1 parent ad9b64c commit 257b368
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions service/src/scripts/archive-ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
/* eslint-disable no-console, no-process-exit, unicorn/no-process-exit */
import '@oada/pino-debug';

import { doSyncTicketJob, makeSyncTicketJob } from '../services/syncTicket.js';
import { argv } from 'node:process';
import { connect } from '@oada/client';
import { doSyncTicketJob } from '../services/syncTicket.js';

import { config } from '../config.js';

Expand All @@ -29,16 +29,28 @@ const oada = await connect({ token, domain });

/* A quick script to move an EntryId to a new location */

if (argv.length !== 3) {
console.error('USAGE: node archive-ticket.js ticketId');
if (argv.length !== 3 && argv.length !== 4) {
console.error('USAGE: node archive-ticket.js ticketId <NOW/queue>');
process.exit(1);
}

const type =
argv.length === 4
? (argv[3] ?? '').toLowerCase() === 'now'
? 'now'
: 'queue'
: 'now';

const ticketId = Number(argv[2]); // As unknown as EntryId;
await doSyncTicketJob(oada, {
ticketId,
archivers: config.get('service.poller.archivers'),
});
await (type === 'now'
? doSyncTicketJob(oada, {
ticketId,
archivers: config.get('service.poller.archivers'),
})
: makeSyncTicketJob(oada, {
ticketId,
archivers: config.get('service.poller.archivers'),
}));

console.info(`Created archive job for ticket ${ticketId}`);
process.exit(0);

0 comments on commit 257b368

Please sign in to comment.