mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -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
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user