[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2026-01-16 17:35:04 +00:00 committed by GitHub
parent 1ce2b10a10
commit b8ee80fd76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 8 deletions

View File

@ -140,7 +140,11 @@ async function createTables() {
table.integer("ping");
table.integer("duration").notNullable().defaultTo(0);
table.integer("down_count").notNullable().defaultTo(0);
table.float("numeric_value").nullable().defaultTo(null).comment("Numeric value from monitor check (e.g., from JSON query or SNMP)");
table
.float("numeric_value")
.nullable()
.defaultTo(null)
.comment("Numeric value from monitor check (e.g., from JSON query or SNMP)");
table.index("important");
table.index(["monitor_id", "time"], "monitor_time_index");

View File

@ -1,6 +1,10 @@
exports.up = function (knex) {
return knex.schema.alterTable("heartbeat", function (table) {
table.float("numeric_value").nullable().defaultTo(null).comment("Numeric value from monitor check (e.g., from JSON query or SNMP)");
table
.float("numeric_value")
.nullable()
.defaultTo(null)
.comment("Numeric value from monitor check (e.g., from JSON query or SNMP)");
});
};
@ -9,4 +13,3 @@ exports.down = function (knex) {
table.dropColumn("numeric_value");
});
};

View File

@ -66,8 +66,14 @@ module.exports.chartSocketHandler = (socket) => {
.filter((entry) => entry.avgNumeric !== null && entry.avgNumeric !== undefined)
.map((entry) => ({
value: parseFloat(entry.avgNumeric),
min: entry.minNumeric !== null && entry.minNumeric !== undefined ? parseFloat(entry.minNumeric) : null,
max: entry.maxNumeric !== null && entry.maxNumeric !== undefined ? parseFloat(entry.maxNumeric) : null,
min:
entry.minNumeric !== null && entry.minNumeric !== undefined
? parseFloat(entry.minNumeric)
: null,
max:
entry.maxNumeric !== null && entry.maxNumeric !== undefined
? parseFloat(entry.maxNumeric)
: null,
timestamp: entry.timestamp,
time: dayjs.unix(entry.timestamp).utc().format("YYYY-MM-DD HH:mm:ss"),
}));

View File

@ -143,7 +143,8 @@ class UptimeCalculator {
avgNumeric: bean.numeric_value,
minNumeric: bean.numeric_min,
maxNumeric: bean.numeric_max,
sumNumeric: bean.numeric_value !== null && bean.numeric_value !== undefined ? bean.numeric_value * bean.up : 0,
sumNumeric:
bean.numeric_value !== null && bean.numeric_value !== undefined ? bean.numeric_value * bean.up : 0,
};
if (bean.extras != null) {
@ -173,7 +174,8 @@ class UptimeCalculator {
avgNumeric: bean.numeric_value,
minNumeric: bean.numeric_min,
maxNumeric: bean.numeric_max,
sumNumeric: bean.numeric_value !== null && bean.numeric_value !== undefined ? bean.numeric_value * bean.up : 0,
sumNumeric:
bean.numeric_value !== null && bean.numeric_value !== undefined ? bean.numeric_value * bean.up : 0,
};
if (bean.extras != null) {
@ -202,7 +204,8 @@ class UptimeCalculator {
avgNumeric: bean.numeric_value,
minNumeric: bean.numeric_min,
maxNumeric: bean.numeric_max,
sumNumeric: bean.numeric_value !== null && bean.numeric_value !== undefined ? bean.numeric_value * bean.up : 0,
sumNumeric:
bean.numeric_value !== null && bean.numeric_value !== undefined ? bean.numeric_value * bean.up : 0,
};
if (bean.extras != null) {