mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-18 01:44:53 +00:00
fix(tasks): restore INDEX_OPTIMIZE enum and remove no-op run button
INDEX_OPTIMIZE was dropped from the TaskType enum but still referenced in _RUNNABLE_TASKS (views.py) and the frontend system-status-dialog, causing an AttributeError at import time. Restore the enum value in the model and migration so the serializer accepts it, but remove it from _RUNNABLE_TASKS since index_optimize is a Tantivy no-op. Remove the frontend "Run Task" button for index optimization accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
14931c02e6
commit
9521e89680
-10
@@ -168,16 +168,6 @@
|
||||
<i-bs name="exclamation-triangle-fill" class="text-danger ms-2 lh-1"></i-bs>
|
||||
}
|
||||
</button>
|
||||
@if (currentUserIsSuperUser) {
|
||||
@if (isRunning(PaperlessTaskType.IndexOptimize)) {
|
||||
<div class="spinner-border spinner-border-sm ms-2" role="status"></div>
|
||||
} @else {
|
||||
<button class="btn btn-sm d-flex align-items-center btn-dark small ms-2" (click)="runTask(PaperlessTaskType.IndexOptimize)">
|
||||
<i-bs name="play-fill" class="me-1"></i-bs>
|
||||
<ng-container i18n>Run Task</ng-container>
|
||||
</button>
|
||||
}
|
||||
}
|
||||
</dd>
|
||||
<ng-template #indexStatus>
|
||||
@if (status.tasks.index_status === 'OK') {
|
||||
|
||||
+9
-9
@@ -138,9 +138,9 @@ describe('SystemStatusDialogComponent', () => {
|
||||
})
|
||||
|
||||
it('should check if task is running', () => {
|
||||
component.runTask(PaperlessTaskType.IndexOptimize)
|
||||
expect(component.isRunning(PaperlessTaskType.IndexOptimize)).toBeTruthy()
|
||||
expect(component.isRunning(PaperlessTaskType.SanityCheck)).toBeFalsy()
|
||||
component.runTask(PaperlessTaskType.SanityCheck)
|
||||
expect(component.isRunning(PaperlessTaskType.SanityCheck)).toBeTruthy()
|
||||
expect(component.isRunning(PaperlessTaskType.TrainClassifier)).toBeFalsy()
|
||||
})
|
||||
|
||||
it('should support running tasks, refresh status and show toasts', () => {
|
||||
@@ -151,22 +151,22 @@ describe('SystemStatusDialogComponent', () => {
|
||||
|
||||
// fail first
|
||||
runSpy.mockReturnValue(throwError(() => new Error('error')))
|
||||
component.runTask(PaperlessTaskType.IndexOptimize)
|
||||
expect(runSpy).toHaveBeenCalledWith(PaperlessTaskType.IndexOptimize)
|
||||
component.runTask(PaperlessTaskType.SanityCheck)
|
||||
expect(runSpy).toHaveBeenCalledWith(PaperlessTaskType.SanityCheck)
|
||||
expect(toastErrorSpy).toHaveBeenCalledWith(
|
||||
`Failed to start task ${PaperlessTaskType.IndexOptimize}, see the logs for more details`,
|
||||
`Failed to start task ${PaperlessTaskType.SanityCheck}, see the logs for more details`,
|
||||
expect.any(Error)
|
||||
)
|
||||
|
||||
// succeed
|
||||
runSpy.mockReturnValue(of({}))
|
||||
getStatusSpy.mockReturnValue(of(status))
|
||||
component.runTask(PaperlessTaskType.IndexOptimize)
|
||||
expect(runSpy).toHaveBeenCalledWith(PaperlessTaskType.IndexOptimize)
|
||||
component.runTask(PaperlessTaskType.SanityCheck)
|
||||
expect(runSpy).toHaveBeenCalledWith(PaperlessTaskType.SanityCheck)
|
||||
|
||||
expect(getStatusSpy).toHaveBeenCalled()
|
||||
expect(toastSpy).toHaveBeenCalledWith(
|
||||
`Task ${PaperlessTaskType.IndexOptimize} started`
|
||||
`Task ${PaperlessTaskType.SanityCheck} started`
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ class Migration(migrations.Migration):
|
||||
("consume_file", "Consume File"),
|
||||
("train_classifier", "Train Classifier"),
|
||||
("sanity_check", "Sanity Check"),
|
||||
("index_optimize", "Index Optimize"),
|
||||
("mail_fetch", "Mail Fetch"),
|
||||
("llm_index", "LLM Index"),
|
||||
("empty_trash", "Empty Trash"),
|
||||
|
||||
@@ -682,6 +682,7 @@ class PaperlessTask(ModelWithOwner):
|
||||
CONSUME_FILE = "consume_file", _("Consume File")
|
||||
TRAIN_CLASSIFIER = "train_classifier", _("Train Classifier")
|
||||
SANITY_CHECK = "sanity_check", _("Sanity Check")
|
||||
INDEX_OPTIMIZE = "index_optimize", _("Index Optimize")
|
||||
MAIL_FETCH = "mail_fetch", _("Mail Fetch")
|
||||
LLM_INDEX = "llm_index", _("LLM Index")
|
||||
EMPTY_TRASH = "empty_trash", _("Empty Trash")
|
||||
|
||||
@@ -216,7 +216,6 @@ from documents.signals import document_updated
|
||||
from documents.tasks import build_share_link_bundle
|
||||
from documents.tasks import consume_file
|
||||
from documents.tasks import empty_trash
|
||||
from documents.tasks import index_optimize
|
||||
from documents.tasks import llmindex_index
|
||||
from documents.tasks import sanity_check
|
||||
from documents.tasks import train_classifier
|
||||
@@ -3803,7 +3802,6 @@ class TasksViewSet(ReadOnlyModelViewSet[PaperlessTask]):
|
||||
}
|
||||
|
||||
_RUNNABLE_TASKS = {
|
||||
PaperlessTask.TaskType.INDEX_OPTIMIZE: (index_optimize, {}),
|
||||
PaperlessTask.TaskType.TRAIN_CLASSIFIER: (train_classifier, {}),
|
||||
PaperlessTask.TaskType.SANITY_CHECK: (sanity_check, {"raise_on_error": False}),
|
||||
PaperlessTask.TaskType.LLM_INDEX: (llmindex_index, {"rebuild": False}),
|
||||
|
||||
Reference in New Issue
Block a user