Support acknowledged param

This commit is contained in:
shamoon 2025-02-14 15:39:10 -08:00
parent e1b944ce6b
commit f3438914cc
6 changed files with 33 additions and 27 deletions

View File

@ -162,7 +162,9 @@ describe('TasksComponent', () => {
jest.useFakeTimers() jest.useFakeTimers()
fixture.detectChanges() fixture.detectChanges()
httpTestingController httpTestingController
.expectOne(`${environment.apiBaseUrl}tasks/?task_name=consume_file`) .expectOne(
`${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
)
.flush(tasks) .flush(tasks)
}) })

View File

@ -37,7 +37,7 @@ describe('TasksService', () => {
it('calls tasks api endpoint on reload', () => { it('calls tasks api endpoint on reload', () => {
tasksService.reload() tasksService.reload()
const req = httpTestingController.expectOne( const req = httpTestingController.expectOne(
`${environment.apiBaseUrl}tasks/?task_name=consume_file` `${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
) )
expect(req.request.method).toEqual('GET') expect(req.request.method).toEqual('GET')
}) })
@ -46,7 +46,7 @@ describe('TasksService', () => {
tasksService.loading = true tasksService.loading = true
tasksService.reload() tasksService.reload()
httpTestingController.expectNone( httpTestingController.expectNone(
`${environment.apiBaseUrl}tasks/?task_name=consume_file` `${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
) )
}) })
@ -62,7 +62,9 @@ describe('TasksService', () => {
req.flush([]) req.flush([])
// reload is then called // reload is then called
httpTestingController httpTestingController
.expectOne(`${environment.apiBaseUrl}tasks/?task_name=consume_file`) .expectOne(
`${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
)
.flush([]) .flush([])
}) })
@ -119,7 +121,7 @@ describe('TasksService', () => {
tasksService.reload() tasksService.reload()
const req = httpTestingController.expectOne( const req = httpTestingController.expectOne(
`${environment.apiBaseUrl}tasks/?task_name=consume_file` `${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
) )
req.flush(mockTasks) req.flush(mockTasks)

View File

@ -54,7 +54,9 @@ export class TasksService {
this.loading = true this.loading = true
this.http this.http
.get<PaperlessTask[]>(`${this.baseUrl}tasks/?task_name=consume_file`) .get<PaperlessTask[]>(
`${this.baseUrl}tasks/?task_name=consume_file&acknowledged=false`
)
.pipe(takeUntil(this.unsubscribeNotifer), first()) .pipe(takeUntil(this.unsubscribeNotifer), first())
.subscribe((r) => { .subscribe((r) => {
this.fileTasks = r.filter((t) => t.type == PaperlessTaskType.Auto) this.fileTasks = r.filter((t) => t.type == PaperlessTaskType.Auto)

View File

@ -772,6 +772,11 @@ class ShareLinkFilterSet(FilterSet):
class PaperlessTaskFilterSet(FilterSet): class PaperlessTaskFilterSet(FilterSet):
acknowledged = BooleanFilter(
label="Acknowledged",
field_name="acknowledged",
)
class Meta: class Meta:
model = PaperlessTask model = PaperlessTask
fields = { fields = {

View File

@ -1708,6 +1708,7 @@ class TasksViewSerializer(OwnedObjectSerializer):
def get_related_document(self, obj) -> str | None: def get_related_document(self, obj) -> str | None:
result = None result = None
re = None re = None
if obj.result:
match obj.status: match obj.status:
case states.SUCCESS: case states.SUCCESS:
re = self.created_doc_re re = self.created_doc_re

View File

@ -2233,13 +2233,7 @@ class TasksViewSet(ReadOnlyModelViewSet):
filterset_class = PaperlessTaskFilterSet filterset_class = PaperlessTaskFilterSet
def get_queryset(self): def get_queryset(self):
queryset = ( queryset = PaperlessTask.objects.all().order_by("date_created").reverse()
PaperlessTask.objects.filter(
acknowledged=False,
)
.order_by("date_created")
.reverse()
)
task_id = self.request.query_params.get("task_id") task_id = self.request.query_params.get("task_id")
if task_id is not None: if task_id is not None:
queryset = PaperlessTask.objects.filter(task_id=task_id) queryset = PaperlessTask.objects.filter(task_id=task_id)