Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { TestBed } from "@angular/core/testing";
import {
ALL_COLUMNS,
OperatorPaginationResultService,
OperatorResultService,
WorkflowResultService,
Expand Down Expand Up @@ -474,6 +475,15 @@ describe("OperatorPaginationResultService", () => {
expect((service as any).pendingRequests.size).toBe(0);
});

it("asks for every column within the server's Int when no column limit is given", () => {
service.selectPage(3, 10).subscribe();

expect(mockWorkflowWebsocketService.send).toHaveBeenCalledWith(
"ResultPaginationRequest",
expect.objectContaining({ columnLimit: ALL_COLUMNS })
);
});

it("bypasses the frontend cache when column filters are set", () => {
(service as any).resultCache.set(2, [{ id: 1 }]);
service.selectPage(2, 10, 5).subscribe();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ export class OperatorResultService {
}
}

/**
* A column limit that asks for every column. The server reads the limit as a 32-bit Int, so it is
* Int.MaxValue there; Number.MAX_SAFE_INTEGER fails to parse and the request is never answered.
*/
export const ALL_COLUMNS = 2147483647;

export class OperatorPaginationResultService {
private pendingRequests: Map<string, Subject<PaginatedResultEvent>> = new Map();
private resultCache: Map<number, ReadonlyArray<object>> = new Map();
Expand Down Expand Up @@ -317,14 +323,13 @@ export class OperatorPaginationResultService {
pageIndex: number,
pageSize: number,
columnOffset: number = 0,
columnLimit: number = Number.MAX_SAFE_INTEGER,
columnLimit: number = ALL_COLUMNS,
columnSearch: string = ""
): Observable<PaginatedResultEvent> {
// update currently selected page
this.currentPageIndex = pageIndex;
// first fetch from frontend result cache
const useCache =
this.portIndex === 0 && columnOffset === 0 && columnLimit === Number.MAX_SAFE_INTEGER && columnSearch === "";
const useCache = this.portIndex === 0 && columnOffset === 0 && columnLimit === ALL_COLUMNS && columnSearch === "";
const pageCache = useCache ? this.resultCache.get(pageIndex) : undefined;
if (pageCache) {
return of(<PaginatedResultEvent>{
Expand Down
Loading