Skip to content

Commit

Permalink
feat: add batch reprocess support (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyg603 authored Jun 9, 2023
1 parent 8718679 commit 14f9359
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/crash/crash-api-client/crash-api-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('CrashApiClient', () => {
await client.reprocessCrash(database, 0);
fail('reprocessCrash was supposed to throw!');
} catch (error: any) {
expect(error.message).toMatch(/to be a positive non-zero number/);
expect(error.message).toMatch(/to be positive non-zero numbers/);
}
});
});
Expand Down
13 changes: 10 additions & 3 deletions src/crash/crash-api-client/crash-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,22 @@ export class CrashApiClient {
}

async reprocessCrash(database: string, crashId: number, force = false, processor = ''): Promise<SuccessResponse> {
return this.reprocessCrashes(database, [crashId], force, processor);
}

async reprocessCrashes(database: string, crashIds: Array<number>, force = false, processor = ''): Promise<SuccessResponse> {
ac.assertNonWhiteSpaceString(database, 'database');
ac.assertBoolean(force, 'force');
if (crashId <= 0) {
throw new Error(`Expected id to be a positive non-zero number. Value received: "${crashId}"`);

for (const crashId of crashIds) {
if (crashId <= 0) {
throw new Error(`Expected ids to be positive non-zero numbers. Value received: "${crashId}"`);
}
}

const formData = this._client.createFormData();
formData.append('database', database);
formData.append('id', crashId.toString());
formData.append('id', crashIds.join(','));
formData.append('force', force.toString());
if (processor) {
formData.append('processor', processor);
Expand Down

0 comments on commit 14f9359

Please sign in to comment.