Adapt Row.svelte to new urql version

- Fixes data not loading on metric changes
This commit is contained in:
Christoph Kluge 2023-05-09 11:58:57 +02:00
parent 3afcd061ef
commit 59a99b75e3

View File

@ -25,48 +25,53 @@
let scopes = [job.numNodes == 1 ? "core" : "node"]; let scopes = [job.numNodes == 1 ? "core" : "node"];
const cluster = getContext("clusters").find((c) => c.name == job.cluster); const cluster = getContext("clusters").find((c) => c.name == job.cluster);
// Get all MetricConfs which include subCluster-specific settings for this job const metricConfig = getContext("metrics"); // Get all MetricConfs which include subCluster-specific settings for this job
const metricConfig = getContext("metrics"); const client = getContextClient();
const metricsQuery = queryStore({ const query = gql`
client: getContextClient(), query ($id: ID!, $metrics: [String!]!, $scopes: [MetricScope!]!) {
query: gql` jobMetrics(id: $id, metrics: $metrics, scopes: $scopes) {
query ($id: ID!, $metrics: [String!]!, $scopes: [MetricScope!]!) { name
jobMetrics(id: $id, metrics: $metrics, scopes: $scopes) { scope
name metric {
scope unit {
metric { prefix
unit { base
prefix }
base timestep
} statisticsSeries {
timestep min
statisticsSeries { mean
max
}
series {
hostname
id
data
statistics {
min min
mean avg
max max
} }
series {
hostname
id
data
statistics {
min
avg
max
}
}
} }
} }
} }
`, }
pause: true, `;
variables: {
id, $: metricsQuery = queryStore({
metrics, client,
scopes, query,
}, variables: { id, metrics, scopes },
}); });
function refresh() {
queryStore({
client,
query,
variables: { id, metrics, scopes },
});
}
const selectScope = (jobMetrics) => const selectScope = (jobMetrics) =>
jobMetrics.reduce( jobMetrics.reduce(
(a, b) => (a, b) =>
@ -131,9 +136,7 @@
} }
}); });
// $: metricsQuery.variables = { id: job.id, metrics, scopes }; if (job.monitoringStatus) refresh();
if (job.monitoringStatus) metricsQuery.resume();
</script> </script>
<tr> <tr>