-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19356 from GordonSmith/HPCC-33117-WUQUERY_WUMONITOR
HPCC-33117 Switch Workunits page to use @hpcc-js/comms fully
- Loading branch information
Showing
2 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Workunit, WorkunitsService, type WsWorkunits } from "@hpcc-js/comms"; | ||
import { Thenable } from "src/store/Deferred"; | ||
import { Paged } from "src/store/Paged"; | ||
import { BaseStore } from "src/store/Store"; | ||
import { wuidToDateTime } from "src/Utility"; | ||
|
||
const service = new WorkunitsService({ baseUrl: "" }); | ||
|
||
export type WUQueryStore = BaseStore<WsWorkunits.WUQuery, Workunit>; | ||
|
||
export function CreateWUQueryStore(): BaseStore<WsWorkunits.WUQuery, Workunit> { | ||
const store = new Paged<WsWorkunits.WUQuery, Workunit>({ | ||
start: "PageStartFrom", | ||
count: "PageSize", | ||
sortBy: "Sortby", | ||
descending: "Descending" | ||
}, "Wuid", (request, abortSignal): Thenable<{ data: Workunit[], total: number }> => { | ||
if (request.Sortby && request.Sortby === "TotalClusterTime") { | ||
request.Sortby = "ClusterTime"; | ||
} | ||
return service.WUQuery(request, abortSignal).then(response => { | ||
const page = { | ||
start: undefined, | ||
end: undefined | ||
}; | ||
const data = response.Workunits.ECLWorkunit.map((wu): Workunit => { | ||
const start = wuidToDateTime(wu.Wuid); | ||
if (!page.start || page.start > start) { | ||
page.start = start; | ||
} | ||
let timePartsSection = 0; | ||
const end = new Date(start); | ||
const timeParts = wu.TotalClusterTime?.split(":") ?? []; | ||
while (timeParts.length) { | ||
const timePart = timeParts.pop(); | ||
switch (timePartsSection) { | ||
case 0: | ||
end.setSeconds(end.getSeconds() + +timePart); | ||
break; | ||
case 1: | ||
end.setMinutes(end.getMinutes() + +timePart); | ||
break; | ||
case 2: | ||
end.setHours(end.getHours() + +timePart); | ||
break; | ||
case 3: | ||
end.setDate(end.getDate() + +timePart); | ||
break; | ||
} | ||
++timePartsSection; | ||
} | ||
if (!page.end || page.end < end) { | ||
page.end = end; | ||
} | ||
const retVal = Workunit.attach(service, wu.Wuid, wu); | ||
// HPCC-33121 - Move to @hpcc-js/comms --- | ||
retVal["__timeline_timings"] = { | ||
start, | ||
end, | ||
page | ||
}; | ||
return retVal; | ||
}); | ||
return { | ||
data, | ||
total: response.NumWUs | ||
}; | ||
}); | ||
}); | ||
return store; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters