From 4ba384bf1ef3dce2a88464ba3cfd09f58ff222d7 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:19:11 -0700 Subject: [PATCH] Fix: ignore incomplete tasks for system status 'last run' --- src/documents/views.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/documents/views.py b/src/documents/views.py index 111df9f2f..90315aa9b 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -2836,6 +2836,11 @@ class SystemStatusView(PassUserMixin): last_trained_task = ( PaperlessTask.objects.filter( task_name=PaperlessTask.TaskName.TRAIN_CLASSIFIER, + status__in=[ + states.SUCCESS, + states.FAILURE, + states.REVOKED, + ], # ignore running tasks ) .order_by("-date_done") .first() @@ -2845,7 +2850,7 @@ class SystemStatusView(PassUserMixin): if last_trained_task is None: classifier_status = "WARNING" classifier_error = "No classifier training tasks found" - elif last_trained_task and last_trained_task.status == states.FAILURE: + elif last_trained_task and last_trained_task.status != states.SUCCESS: classifier_status = "ERROR" classifier_error = last_trained_task.result classifier_last_trained = ( @@ -2855,6 +2860,11 @@ class SystemStatusView(PassUserMixin): last_sanity_check = ( PaperlessTask.objects.filter( task_name=PaperlessTask.TaskName.CHECK_SANITY, + status__in=[ + states.SUCCESS, + states.FAILURE, + states.REVOKED, + ], # ignore running tasks ) .order_by("-date_done") .first() @@ -2864,7 +2874,7 @@ class SystemStatusView(PassUserMixin): if last_sanity_check is None: sanity_check_status = "WARNING" sanity_check_error = "No sanity check tasks found" - elif last_sanity_check and last_sanity_check.status == states.FAILURE: + elif last_sanity_check and last_sanity_check.status != states.SUCCESS: sanity_check_status = "ERROR" sanity_check_error = last_sanity_check.result sanity_check_last_run = ( -- 2.47.2