Skip to content

Commit 23c2d1c

Browse files
authored
Merge pull request #4437 from jeclrsg/wuResult-bypass-cache
feat(comms): allow WUResult to set BypassCachedResult in request
2 parents 49ba456 + 0405d6c commit 23c2d1c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

packages/comms/src/ecl/result.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type UResulState = ECLResultEx & WsDfu.DFULogicalFile;
4747
export type IResulState = ECLResultEx | WsDfu.DFULogicalFile;
4848
export class Result extends StateObject<UResulState, IResulState> implements ECLResultEx {
4949
protected connection: WorkunitsService;
50+
protected _bypassCache: boolean = false;
5051
get BaseUrl() { return this.connection.baseUrl; }
5152
protected xsdSchema: XSDSchema;
5253

@@ -145,6 +146,12 @@ export class Result extends StateObject<UResulState, IResulState> implements ECL
145146
return this.Total !== -1;
146147
}
147148

149+
bypassCache(bypass?: boolean): boolean | this {
150+
if (bypass === undefined) return this._bypassCache;
151+
this._bypassCache = bypass;
152+
return this;
153+
}
154+
148155
private _fetchXMLSchemaPromise: Promise<XSDSchema | null>;
149156
fetchXMLSchema(refresh = false): Promise<XSDSchema | null> {
150157
if (!this._fetchXMLSchemaPromise || refresh) {
@@ -164,8 +171,9 @@ export class Result extends StateObject<UResulState, IResulState> implements ECL
164171
return this;
165172
}
166173

167-
fetchRows(from: number = 0, count: number = -1, includeSchema: boolean = false, filter: ResultFilter = {}, abortSignal?: AbortSignal): Promise<any[]> {
168-
return this.WUResult(from, count, !includeSchema, filter, abortSignal).then((response) => {
174+
fetchRows(from: number = 0, count: number = -1, includeSchema: boolean = false, filter: ResultFilter = {}, abortSignal?: AbortSignal, bypassCache?: boolean): Promise<any[]> {
175+
const shouldBypassCache = bypassCache ?? this._bypassCache;
176+
return this.WUResult(from, count, !includeSchema, filter, abortSignal, shouldBypassCache).then((response) => {
169177
const result: any = response.Result;
170178
delete response.Result; // Do not want it in "set"
171179
this.set({
@@ -193,7 +201,7 @@ export class Result extends StateObject<UResulState, IResulState> implements ECL
193201
return this.xsdSchema.root.children();
194202
}
195203

196-
protected WUResult(start: number = 0, count: number = 1, suppressXmlSchema: boolean = false, filter: { [key: string]: string | number } = {}, abortSignal?: AbortSignal): Promise<WUResultResponseEx> {
204+
protected WUResult(start: number = 0, count: number = 1, suppressXmlSchema: boolean = false, filter: { [key: string]: string | number } = {}, abortSignal?: AbortSignal, bypassCache: boolean = false): Promise<WUResultResponseEx> {
197205
const FilterBy = {
198206
NamedValue: {
199207
itemcount: 0
@@ -221,6 +229,7 @@ export class Result extends StateObject<UResulState, IResulState> implements ECL
221229
request.Start = start;
222230
request.Count = count;
223231
request.SuppressXmlSchema = suppressXmlSchema;
232+
request.BypassCachedResult = bypassCache;
224233
return this.connection.WUResult(request, abortSignal).then((response: unknown) => {
225234
return response as WUResultResponseEx;
226235
});

packages/eclwatch/src/WUResult.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class WUResult extends Common {
2323
logicalFile: this.logicalFile(),
2424
userID: this.user(),
2525
password: this.password(),
26+
bypassCache: this.bypassCache(),
2627
...opts
2728
});
2829
}
@@ -47,6 +48,10 @@ export class WUResult extends Common {
4748
} else if (this.logicalFile()) {
4849
this._result = Result.attachLogicalFile(opts, "", this.logicalFile());
4950
}
51+
52+
if (this._result && this.bypassCache()) {
53+
this._result.bypassCache(this.bypassCache());
54+
}
5055
}
5156
return this._result;
5257
}
@@ -109,6 +114,8 @@ export interface WUResult {
109114
logicalFile(_: string): this;
110115
filter(): ResultFilter;
111116
filter(_: ResultFilter): this;
117+
bypassCache(): boolean;
118+
bypassCache(_: boolean): this;
112119
}
113120

114121
WUResult.prototype.publish("baseUrl", "", "string", "URL to WsWorkunits");
@@ -120,3 +127,4 @@ WUResult.prototype.publish("sequence", undefined, "number", "Sequence Number");
120127
WUResult.prototype.publish("nodeGroup", "", "string", "NodeGroup");
121128
WUResult.prototype.publish("logicalFile", "", "string", "Logical File Name");
122129
WUResult.prototype.publish("filter", {}, "object", "Filter");
130+
WUResult.prototype.publish("bypassCache", false, "boolean", "Bypass cached results");

0 commit comments

Comments
 (0)