Skip to content

Commit

Permalink
Merge pull request #1365 from nationalarchives/feature/auto-re-enrich
Browse files Browse the repository at this point in the history
Add a management command to re-enrich items in the queue
  • Loading branch information
dragon-dxw authored Jan 9, 2024
2 parents ad4fa87 + 9f3d63c commit 2534873
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Empty file.
23 changes: 23 additions & 0 deletions judgments/management/commands/enrich_next_in_reenrichment_queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.core.management.base import BaseCommand

from judgments.utils import api_client

TARGET_ENRICHMENT_VERSION = 6
NUMBER_TO_ENRICH = 1


class Command(BaseCommand):
help = "Sends the next document in the re-enrichment queue to be enriched" ## noqa: A003

def handle(self, *args, **options):
document_details_to_enrich = api_client.get_pending_enrichment_for_version(
TARGET_ENRICHMENT_VERSION,
)

for document_details in document_details_to_enrich[1 : NUMBER_TO_ENRICH + 1]:
document_uri = document_details[0]

document = api_client.get_document_by_uri(document_uri.replace(".xml", ""))

self.stdout.write(f"Sending document {document.name} to enrichment...")
document.enrich()

0 comments on commit 2534873

Please sign in to comment.