mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Enhancement: speed up merge document list retrieval
This commit is contained in:
		| @@ -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() | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|       }) | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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])) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon