Skip to content

Commit

Permalink
delete treatments before reannotate (#94)
Browse files Browse the repository at this point in the history
Co-authored-by: Antoine Jeanneney <[email protected]>
  • Loading branch information
ajeanneney and Antoine Jeanneney committed Apr 5, 2024
1 parent 373020a commit ea02780
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Purge db (for now only the statistics after 6 months).

## reAnnotateFreeDocuments

If the NLP API was outdated or buggy, reannotate free documents. Warning: this script has not been tested since a while (possible bug: treatments are not deleted).
If the NLP API was outdated or buggy, reannotate free documents. Warning: suspend nlp-annotation job during this operation to avoid side effects.

## renewCache

Expand Down
6 changes: 6 additions & 0 deletions packages/generic/backend/src/lib/annotator/buildAnnotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ function buildAnnotator(
async function reAnnotateFreeDocuments() {
const documentIds = await documentService.fetchFreeDocumentsIds();

logger.log({
operationName: 'reAnnotateFreeDocuments',
msg: `Found ${documentIds.length} free documents to reannotate, deleting their treatments`,
});

for (const documentId of documentIds) {
await treatmentService.deleteTreatmentsByDocumentId(documentId);
await documentService.updateDocumentStatus(documentId, 'loaded');
}

Expand Down

0 comments on commit ea02780

Please sign in to comment.