Enhancement: add --id-range for document_retagger (#4080)

---------

Co-authored-by: Trenton H <797416+stumpylog@users.noreply.github.com>
This commit is contained in:
Kamil Kosek
2023-09-08 19:33:24 +02:00
committed by GitHub
parent f58b09b71a
commit addc116f55
3 changed files with 55 additions and 1 deletions

View File

@@ -63,6 +63,12 @@ class Command(BaseCommand):
"--base-url",
help="The base URL to use to build the link to the documents.",
)
parser.add_argument(
"--id-range",
help="A range of document ids on which the retagging should be applied.",
nargs=2,
type=int,
)
def handle(self, *args, **options):
# Detect if we support color
@@ -72,6 +78,12 @@ class Command(BaseCommand):
queryset = Document.objects.filter(tags__is_inbox_tag=True)
else:
queryset = Document.objects.all()
if options["id_range"]:
queryset = queryset.filter(
id__range=(options["id_range"][0], options["id_range"][1]),
)
documents = queryset.distinct()
classifier = load_classifier()