Skip to content

Commit

Permalink
feat: reference the row number as well as claim index in
Browse files Browse the repository at this point in the history
`submit-claims-from-csv` output
  • Loading branch information
timrogers committed Aug 1, 2023
1 parent 9448fa9 commit d81c7e9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/commands/submit-claims-from-csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ command
}

for (const [index, claim] of claims.entries()) {
console.log(`Submitting claim ${index + 1}/${claims.length}`);
const rowNumber = index + 2;
console.log(`Submitting claim ${index + 1}/${claims.length} (row ${rowNumber})`);

try {
if (claim.benefit !== '' && claim.category !== '') {
Expand All @@ -107,9 +108,6 @@ command
accessToken,
);
await createClaim(createClaimOptions);
console.log(
chalk.green(`Successfully submitted claim ${index + 1}/${claims.length}`),
);
} else if (openaiApiKey) {
const benefitsWithCategories = await getBenefitsWithCategories(accessToken);
const { benefit, category } = await attemptToInferCategoryAndBenefit({
Expand All @@ -124,20 +122,25 @@ command
accessToken,
);
await createClaim(createClaimOptions);
console.log(
chalk.green(`Successfully submitted claim ${index + 1}/${claims.length}`),
);
} else {
throw new Error(
'You must either fill out the `benefit` and `category` columns, or specify an OpenAI API key.',
);
}

console.log(
chalk.green(
`Successfully submitted claim ${index + 1}/${
claims.length
} (row ${rowNumber})`,
),
);
} catch (e) {
console.error(
chalk.red(
`Error submitting claim ${index + 1}/${claims.length}: ${serializeError(
e,
)}`,
)} (row ${rowNumber})`,
),
);
}
Expand Down

0 comments on commit d81c7e9

Please sign in to comment.