diff --git a/packages/comms/src/ecl/result.ts b/packages/comms/src/ecl/result.ts index 99d34f48dc..fcd07a9991 100644 --- a/packages/comms/src/ecl/result.ts +++ b/packages/comms/src/ecl/result.ts @@ -47,6 +47,7 @@ export type UResulState = ECLResultEx & WsDfu.DFULogicalFile; export type IResulState = ECLResultEx | WsDfu.DFULogicalFile; export class Result extends StateObject implements ECLResultEx { protected connection: WorkunitsService; + protected _bypassCache: boolean = false; get BaseUrl() { return this.connection.baseUrl; } protected xsdSchema: XSDSchema; @@ -145,6 +146,12 @@ export class Result extends StateObject implements ECL return this.Total !== -1; } + bypassCache(bypass?: boolean): boolean | this { + if (bypass === undefined) return this._bypassCache; + this._bypassCache = bypass; + return this; + } + private _fetchXMLSchemaPromise: Promise; fetchXMLSchema(refresh = false): Promise { if (!this._fetchXMLSchemaPromise || refresh) { @@ -164,8 +171,9 @@ export class Result extends StateObject implements ECL return this; } - fetchRows(from: number = 0, count: number = -1, includeSchema: boolean = false, filter: ResultFilter = {}, abortSignal?: AbortSignal): Promise { - return this.WUResult(from, count, !includeSchema, filter, abortSignal).then((response) => { + fetchRows(from: number = 0, count: number = -1, includeSchema: boolean = false, filter: ResultFilter = {}, abortSignal?: AbortSignal, bypassCache?: boolean): Promise { + const shouldBypassCache = bypassCache ?? this._bypassCache; + return this.WUResult(from, count, !includeSchema, filter, abortSignal, shouldBypassCache).then((response) => { const result: any = response.Result; delete response.Result; // Do not want it in "set" this.set({ @@ -193,7 +201,7 @@ export class Result extends StateObject implements ECL return this.xsdSchema.root.children(); } - protected WUResult(start: number = 0, count: number = 1, suppressXmlSchema: boolean = false, filter: { [key: string]: string | number } = {}, abortSignal?: AbortSignal): Promise { + protected WUResult(start: number = 0, count: number = 1, suppressXmlSchema: boolean = false, filter: { [key: string]: string | number } = {}, abortSignal?: AbortSignal, bypassCache: boolean = false): Promise { const FilterBy = { NamedValue: { itemcount: 0 @@ -221,6 +229,7 @@ export class Result extends StateObject implements ECL request.Start = start; request.Count = count; request.SuppressXmlSchema = suppressXmlSchema; + request.BypassCachedResult = bypassCache; return this.connection.WUResult(request, abortSignal).then((response: unknown) => { return response as WUResultResponseEx; }); diff --git a/packages/eclwatch/src/WUResult.ts b/packages/eclwatch/src/WUResult.ts index 53c6b8d1b8..9f8bc207e2 100644 --- a/packages/eclwatch/src/WUResult.ts +++ b/packages/eclwatch/src/WUResult.ts @@ -23,6 +23,7 @@ export class WUResult extends Common { logicalFile: this.logicalFile(), userID: this.user(), password: this.password(), + bypassCache: this.bypassCache(), ...opts }); } @@ -47,6 +48,10 @@ export class WUResult extends Common { } else if (this.logicalFile()) { this._result = Result.attachLogicalFile(opts, "", this.logicalFile()); } + + if (this._result && this.bypassCache()) { + this._result.bypassCache(this.bypassCache()); + } } return this._result; } @@ -109,6 +114,8 @@ export interface WUResult { logicalFile(_: string): this; filter(): ResultFilter; filter(_: ResultFilter): this; + bypassCache(): boolean; + bypassCache(_: boolean): this; } WUResult.prototype.publish("baseUrl", "", "string", "URL to WsWorkunits"); @@ -120,3 +127,4 @@ WUResult.prototype.publish("sequence", undefined, "number", "Sequence Number"); WUResult.prototype.publish("nodeGroup", "", "string", "NodeGroup"); WUResult.prototype.publish("logicalFile", "", "string", "Logical File Name"); WUResult.prototype.publish("filter", {}, "object", "Filter"); +WUResult.prototype.publish("bypassCache", false, "boolean", "Bypass cached results");