]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Enhancement: speed up merge document list retrieval
authorshamoon <4887959+shamoon@users.noreply.github.com>
Fri, 19 Apr 2024 17:04:10 +0000 (10:04 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Fri, 19 Apr 2024 17:17:17 +0000 (10:17 -0700)
src-ui/src/app/components/common/confirm-dialog/merge-confirm-dialog/merge-confirm-dialog.component.spec.ts
src-ui/src/app/components/common/confirm-dialog/merge-confirm-dialog/merge-confirm-dialog.component.ts
src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts

index 8b9bf38982641d66e995b68a788bb7becff73893..c4da718171694ab222718288382ebeedd4aca2d6 100644 (file)
@@ -36,14 +36,18 @@ describe('MergeConfirmDialogComponent', () => {
       { id: 2, name: 'Document 2' },
       { id: 3, name: 'Document 3' },
     ]
-    jest.spyOn(documentService, 'getCachedMany').mockReturnValue(of(documents))
+    jest.spyOn(documentService, 'getFew').mockReturnValue(
+      of({
+        all: documents.map((d) => d.id),
+        count: documents.length,
+        results: documents,
+      })
+    )
 
     component.ngOnInit()
 
     expect(component.documents).toEqual(documents)
-    expect(documentService.getCachedMany).toHaveBeenCalledWith(
-      component.documentIDs
-    )
+    expect(documentService.getFew).toHaveBeenCalledWith(component.documentIDs)
   })
 
   it('should move documentIDs on drop', () => {
@@ -64,7 +68,13 @@ describe('MergeConfirmDialogComponent', () => {
       { id: 2, name: 'Document 2' },
       { id: 3, name: 'Document 3' },
     ]
-    jest.spyOn(documentService, 'getCachedMany').mockReturnValue(of(documents))
+    jest.spyOn(documentService, 'getFew').mockReturnValue(
+      of({
+        all: documents.map((d) => d.id),
+        count: documents.length,
+        results: documents,
+      })
+    )
 
     component.ngOnInit()
 
index fd52459e013b8c73b86bb54031dc3d61265b991c..7e64a4f846615c35ca21f9f72a0c8fa4de9f82a8 100644 (file)
@@ -34,10 +34,10 @@ export class MergeConfirmDialogComponent
 
   ngOnInit() {
     this.documentService
-      .getCachedMany(this.documentIDs)
+      .getFew(this.documentIDs)
       .pipe(takeUntil(this.unsubscribeNotifier))
-      .subscribe((documents) => {
-        this._documents = documents
+      .subscribe((r) => {
+        this._documents = r.results
       })
   }
 
index e38138df1e9c2e412d19790b0ec9d9096c281127..127d7ef2b690cdb6ebfab865b479277e1a886a5a 100644 (file)
@@ -866,9 +866,13 @@ describe('BulkEditorComponent', () => {
     jest
       .spyOn(documentListViewService, 'documents', 'get')
       .mockReturnValue([{ id: 3 }, { id: 4 }])
-    jest
-      .spyOn(documentService, 'getCachedMany')
-      .mockReturnValue(of([{ id: 3 }, { id: 4 }]))
+    jest.spyOn(documentService, 'getFew').mockReturnValue(
+      of({
+        all: [3, 4],
+        count: 2,
+        results: [{ id: 3 }, { id: 4 }],
+      })
+    )
     jest
       .spyOn(documentListViewService, 'selected', 'get')
       .mockReturnValue(new Set([3, 4]))