fixed up delay time
This commit is contained in:
parent
d9404c2bda
commit
58c5ba1200
4 changed files with 61 additions and 47 deletions
|
|
@ -6,7 +6,7 @@ const logger = getLogger('batch-helpers');
|
|||
|
||||
// Simple interfaces
|
||||
export interface ProcessOptions {
|
||||
totalDelayMs: number;
|
||||
totalDelayHours: number;
|
||||
batchSize?: number;
|
||||
priority?: number;
|
||||
useBatching?: boolean;
|
||||
|
|
@ -76,7 +76,7 @@ export async function processItems<T>(
|
|||
totalItems: items.length,
|
||||
mode: options.useBatching ? 'batch' : 'direct',
|
||||
batchSize: options.batchSize,
|
||||
totalDelayHours: (options.totalDelayMs / 1000 / 60 / 60).toFixed(1)
|
||||
totalDelayHours: options.totalDelayHours
|
||||
});
|
||||
|
||||
try {
|
||||
|
|
@ -109,7 +109,8 @@ async function processDirect<T>(
|
|||
options: ProcessOptions
|
||||
): Promise<Omit<BatchResult, 'duration'>> {
|
||||
|
||||
const delayPerItem = Math.floor(options.totalDelayMs / items.length);
|
||||
const totalDelayMs = options.totalDelayHours * 60 * 60 * 1000;
|
||||
const delayPerItem = Math.floor(totalDelayMs / items.length);
|
||||
|
||||
logger.info('Creating direct jobs', {
|
||||
totalItems: items.length,
|
||||
|
|
@ -155,7 +156,8 @@ async function processBatched<T>(
|
|||
|
||||
const batchSize = options.batchSize || 100;
|
||||
const batches = createBatches(items, batchSize);
|
||||
const delayPerBatch = Math.floor(options.totalDelayMs / batches.length);
|
||||
const totalDelayMs = options.totalDelayHours * 60 * 60 * 1000;
|
||||
const delayPerBatch = Math.floor(totalDelayMs / batches.length);
|
||||
|
||||
logger.info('Creating batch jobs', {
|
||||
totalItems: items.length,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue