Retry only failed archive results

This commit is contained in:
Nick Sweeting 2026-08-01 11:49:07 -07:00
parent 5423f12474
commit 7dfe9465b4
No known key found for this signature in database
3 changed files with 22 additions and 10 deletions

View File

@ -610,12 +610,12 @@ class SnapshotAdmin(SearchResultsAdminMixin, ConfigEditorMixin, BaseModelAdmin):
if retried:
messages.success(
request,
f"Queued {retried} failed/skipped extractors for retry on this snapshot.",
f"Queued {retried} failed extractors for retry on this snapshot.",
)
else:
messages.info(
request,
"No failed/skipped extractors were found on this snapshot.",
"No failed extractors were found on this snapshot.",
)
return redirect(snapshot.admin_change_url)
@ -1377,10 +1377,10 @@ class SnapshotAdmin(SearchResultsAdminMixin, ConfigEditorMixin, BaseModelAdmin):
if queued:
messages.success(
request,
f"Queued {queued} failed/skipped extractors for retry. The background runner will process them.",
f"Queued {queued} failed extractors for retry. The background runner will process them.",
)
else:
messages.info(request, "No failed/skipped extractors were found in the selected snapshots.")
messages.info(request, "No failed extractors were found in the selected snapshots.")
@admin.action(
description="🆕 Archive Now",

View File

@ -3017,17 +3017,13 @@ class Snapshot(ModelWithDeleteAfter, ModelWithOutputDir, ModelWithConfig, ModelW
def retry_failed_archiveresults(self) -> int:
"""
Reset failed/skipped ArchiveResults to queued for retry.
Reset failed ArchiveResults to queued for retry.
Returns count of ArchiveResults reset.
"""
retryable_results = ArchiveResult.objects.filter(
snapshot=self,
status__in=[
ArchiveResult.StatusChoices.FAILED,
ArchiveResult.StatusChoices.SKIPPED,
ArchiveResult.StatusChoices.NORESULTS,
],
status=ArchiveResult.StatusChoices.FAILED,
)
legacy_result_count = retryable_results.filter(hook_name="").count()
now = timezone.now()

View File

@ -385,6 +385,20 @@ def test_retry_failed_archiveresults_requeues_snapshot_in_queued_state():
output_size=123,
output_mimetypes="text/plain",
)
ArchiveResult.objects.create(
snapshot=snapshot,
plugin="ublock",
hook_name="on_Snapshot__12_ublock",
status=ArchiveResult.StatusChoices.SKIPPED,
output_str="not applicable",
)
ArchiveResult.objects.create(
snapshot=snapshot,
plugin="forumdl",
hook_name="on_Snapshot__50_forumdl",
status=ArchiveResult.StatusChoices.NORESULTS,
output_str="0 outputs",
)
reset_count = snapshot.retry_failed_archiveresults()
@ -402,6 +416,8 @@ def test_retry_failed_archiveresults_requeues_snapshot_in_queued_state():
assert result.output_mimetypes == ""
assert result.start_ts is None
assert result.end_ts is None
assert ArchiveResult.objects.get(snapshot=snapshot, plugin="ublock").status == ArchiveResult.StatusChoices.SKIPPED
assert ArchiveResult.objects.get(snapshot=snapshot, plugin="forumdl").status == ArchiveResult.StatusChoices.NORESULTS
snapshot.refresh_from_db()
assert snapshot.title in (None, "")
_cleanup_machine_process_rows()