mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-17 10:13:56 -05:00
Enhancement: speed up merge document list retrieval
This commit is contained in:
parent
4392628bd7
commit
a47d36f5e5
@ -36,14 +36,18 @@ describe('MergeConfirmDialogComponent', () => {
|
|||||||
{ id: 2, name: 'Document 2' },
|
{ id: 2, name: 'Document 2' },
|
||||||
{ id: 3, name: 'Document 3' },
|
{ 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()
|
component.ngOnInit()
|
||||||
|
|
||||||
expect(component.documents).toEqual(documents)
|
expect(component.documents).toEqual(documents)
|
||||||
expect(documentService.getCachedMany).toHaveBeenCalledWith(
|
expect(documentService.getFew).toHaveBeenCalledWith(component.documentIDs)
|
||||||
component.documentIDs
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should move documentIDs on drop', () => {
|
it('should move documentIDs on drop', () => {
|
||||||
@ -64,7 +68,13 @@ describe('MergeConfirmDialogComponent', () => {
|
|||||||
{ id: 2, name: 'Document 2' },
|
{ id: 2, name: 'Document 2' },
|
||||||
{ id: 3, name: 'Document 3' },
|
{ 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()
|
component.ngOnInit()
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@ export class MergeConfirmDialogComponent
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.documentService
|
this.documentService
|
||||||
.getCachedMany(this.documentIDs)
|
.getFew(this.documentIDs)
|
||||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||||
.subscribe((documents) => {
|
.subscribe((r) => {
|
||||||
this._documents = documents
|
this._documents = r.results
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,9 +866,13 @@ describe('BulkEditorComponent', () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(documentListViewService, 'documents', 'get')
|
.spyOn(documentListViewService, 'documents', 'get')
|
||||||
.mockReturnValue([{ id: 3 }, { id: 4 }])
|
.mockReturnValue([{ id: 3 }, { id: 4 }])
|
||||||
jest
|
jest.spyOn(documentService, 'getFew').mockReturnValue(
|
||||||
.spyOn(documentService, 'getCachedMany')
|
of({
|
||||||
.mockReturnValue(of([{ id: 3 }, { id: 4 }]))
|
all: [3, 4],
|
||||||
|
count: 2,
|
||||||
|
results: [{ id: 3 }, { id: 4 }],
|
||||||
|
})
|
||||||
|
)
|
||||||
jest
|
jest
|
||||||
.spyOn(documentListViewService, 'selected', 'get')
|
.spyOn(documentListViewService, 'selected', 'get')
|
||||||
.mockReturnValue(new Set([3, 4]))
|
.mockReturnValue(new Set([3, 4]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user