Skip to content
Snippets Groups Projects
Commit f10b6a3a authored by Matt's avatar Matt
Browse files

Started round faiilure type differentiation

parent 9ad31b33
No related branches found
No related merge requests found
WITH failed_rounds AS (
WITH precomp_rounds_failed AS (
SELECT
t.node_id,
COUNT(DISTINCT re.round_metric_id)
......@@ -7,7 +7,20 @@ WITH failed_rounds AS (
ON rm.id = t.round_metric_id
RIGHT JOIN round_errors re
ON t.round_metric_id = re.round_metric_id
WHERE rm.realtime_end BETWEEN ? and ?
WHERE rm.precomp_start BETWEEN ? and ?
AND rm.realtime_end = '1970-01-01'::date
GROUP BY t.node_id
), realtime_rounds_failed AS (
SELECT
t.node_id,
COUNT(DISTINCT re.round_metric_id)
FROM topologies t
RIGHT JOIN round_metrics rm
ON rm.id = t.round_metric_id
RIGHT JOIN round_errors re
ON t.round_metric_id = re.round_metric_id
WHERE rm.precomp_start BETWEEN ? and ?
AND rm.realtime_end != '1970-01-01'::date
GROUP BY t.node_id
), participated_rounds AS (
SELECT
......@@ -44,8 +57,9 @@ WITH failed_rounds AS (
)
SELECT
encode(n.id, 'base64') AS node_id,
COALESCE(fr.count::integer, 0) AS rounds_failed,
COALESCE(pr.count::integer, 0) AS rounds_participated,
COALESCE(rfr.count::integer, 0) + COALESCE(pfr.count::integer, 0) AS rounds_failed,
COALESCE(rfr.count::integer, 0) as realtime_rounds_failed,
COALESCE(pfr.count::integer, 0) AS precomp_rounds_failed,
COALESCE(u.uptime_metric_count::integer, 0) as uptime_metric_count,
COALESCE(u.node_metric_count::integer, 0) as node_metric_count,
rp.realtime_avg_seconds AS realtime_avg_seconds,
......@@ -53,7 +67,9 @@ SELECT
? AS interval_start,
? AS interval_end
FROM nodes n
LEFT JOIN failed_rounds fr
LEFT JOIN realtime_rounds_failed rfr
ON fr.node_id = n.id
LEFT JOIN precomp_rounds_failed pfr
ON fr.node_id = n.id
LEFT JOIN participated_rounds pr
ON pr.node_id = n.id
......
exports.up = (knex) => knex.schema.table('node_performance_metrics', (t) => {
t.integer('precomp_rounds_failed').defaultTo(0);
t.integer('realtime_rounds_failed').defaultTo(0);
});
exports.down = (knex) => knex.schema.table('node_performance_metrics', (t) => {
t.dropColumn('precomp_rounds_failed');
t.dropColumn('realtime_rounds_failed');
});
......@@ -4,7 +4,7 @@ const { eventBus } = require('../scripts/refresh_views.js');
const { fetchNetwork } = require('./network');
const { knex: local } = require('../database/local');
const { fetchLastCompletedRound, fetchRoundsAfter, fetchTotalSuccessfulRounds } = require('./rounds');
const { fetchLastCompletedRound, fetchRoundsAfter } = require('./rounds');
const sse = new SSE();
const get = sse.init;
......
......@@ -51,6 +51,8 @@ const formatDblinkQuery = (rawSql, args) => localDb.raw(rawSql, args)
intervalEnd,
intervalStart,
intervalEnd,
intervalStart,
intervalEnd,
].map((t) => t.toISOString());
const formattedPerformanceQuery = formatDblinkQuery(nodePerformancesQuery, args);
......@@ -58,6 +60,8 @@ const formatDblinkQuery = (rawSql, args) => localDb.raw(rawSql, args)
INSERT INTO node_performance_metrics (
node_id,
rounds_failed,
precomp_rounds_failed,
realtime_rounds_failed,
rounds_participated,
uptime_metric_count,
node_metric_count,
......@@ -71,6 +75,8 @@ const formatDblinkQuery = (rawSql, args) => localDb.raw(rawSql, args)
) as t(
node_id text,
rounds_failed integer,
precomp_rounds_failed integer,
realtime_rounds_failed integer,
rounds_partipated integer,
uptime_metric_count integer,
node_metric_count integer,
......@@ -81,6 +87,8 @@ const formatDblinkQuery = (rawSql, args) => localDb.raw(rawSql, args)
) ON CONFLICT (node_id, interval_start)
DO UPDATE SET
rounds_failed = excluded.rounds_failed,
precomp_rounds_failed = excluded.precomp_rounds_failed,
realtime_rounds_failed = excluded.realtime_rounds_failed
rounds_participated = excluded.rounds_participated,
uptime_metric_count = excluded.uptime_metric_count,
node_metric_count = excluded.node_metric_count,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment