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
15 changes: 12 additions & 3 deletions packages/comms/src/ecl/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type UResulState = ECLResultEx & WsDfu.DFULogicalFile;
export type IResulState = ECLResultEx | WsDfu.DFULogicalFile;
export class Result extends StateObject<UResulState, IResulState> implements ECLResultEx {
protected connection: WorkunitsService;
protected _bypassCache: boolean = false;
get BaseUrl() { return this.connection.baseUrl; }
protected xsdSchema: XSDSchema;

Expand Down Expand Up @@ -145,6 +146,12 @@ export class Result extends StateObject<UResulState, IResulState> 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<XSDSchema | null>;
fetchXMLSchema(refresh = false): Promise<XSDSchema | null> {
if (!this._fetchXMLSchemaPromise || refresh) {
Expand All @@ -164,8 +171,9 @@ export class Result extends StateObject<UResulState, IResulState> implements ECL
return this;
}

fetchRows(from: number = 0, count: number = -1, includeSchema: boolean = false, filter: ResultFilter = {}, abortSignal?: AbortSignal): Promise<any[]> {
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<any[]> {
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({
Expand Down Expand Up @@ -193,7 +201,7 @@ export class Result extends StateObject<UResulState, IResulState> 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<WUResultResponseEx> {
protected WUResult(start: number = 0, count: number = 1, suppressXmlSchema: boolean = false, filter: { [key: string]: string | number } = {}, abortSignal?: AbortSignal, bypassCache: boolean = false): Promise<WUResultResponseEx> {
const FilterBy = {
NamedValue: {
itemcount: 0
Expand Down Expand Up @@ -221,6 +229,7 @@ export class Result extends StateObject<UResulState, IResulState> 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;
});
Expand Down
8 changes: 8 additions & 0 deletions packages/eclwatch/src/WUResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class WUResult extends Common {
logicalFile: this.logicalFile(),
userID: this.user(),
password: this.password(),
bypassCache: this.bypassCache(),
...opts
});
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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");
Expand All @@ -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");