[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2026-01-16 11:12:55 +00:00 committed by GitHub
parent 4a4f91e36b
commit 9d6a49255f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 52 deletions

View File

@ -1,55 +1,19 @@
exports.up = function (knex) {
return knex.schema
.alterTable("stat_daily", function (table) {
table
.float("numeric_value")
.nullable()
.defaultTo(null)
.comment("Average numeric value during this period");
table
.float("numeric_min")
.nullable()
.defaultTo(null)
.comment("Minimum numeric value during this period");
table
.float("numeric_max")
.nullable()
.defaultTo(null)
.comment("Maximum numeric value during this period");
table.float("numeric_value").nullable().defaultTo(null).comment("Average numeric value during this period");
table.float("numeric_min").nullable().defaultTo(null).comment("Minimum numeric value during this period");
table.float("numeric_max").nullable().defaultTo(null).comment("Maximum numeric value during this period");
})
.alterTable("stat_hourly", function (table) {
table
.float("numeric_value")
.nullable()
.defaultTo(null)
.comment("Average numeric value during this period");
table
.float("numeric_min")
.nullable()
.defaultTo(null)
.comment("Minimum numeric value during this period");
table
.float("numeric_max")
.nullable()
.defaultTo(null)
.comment("Maximum numeric value during this period");
table.float("numeric_value").nullable().defaultTo(null).comment("Average numeric value during this period");
table.float("numeric_min").nullable().defaultTo(null).comment("Minimum numeric value during this period");
table.float("numeric_max").nullable().defaultTo(null).comment("Maximum numeric value during this period");
})
.alterTable("stat_minutely", function (table) {
table
.float("numeric_value")
.nullable()
.defaultTo(null)
.comment("Average numeric value during this period");
table
.float("numeric_min")
.nullable()
.defaultTo(null)
.comment("Minimum numeric value during this period");
table
.float("numeric_max")
.nullable()
.defaultTo(null)
.comment("Maximum numeric value during this period");
table.float("numeric_value").nullable().defaultTo(null).comment("Average numeric value during this period");
table.float("numeric_min").nullable().defaultTo(null).comment("Minimum numeric value during this period");
table.float("numeric_max").nullable().defaultTo(null).comment("Maximum numeric value during this period");
});
};
@ -71,4 +35,3 @@ exports.down = function (knex) {
table.dropColumn("numeric_max");
});
};

View File

@ -51,7 +51,9 @@ const clearOldData = async () => {
// Clean up old monitor_numeric_history data (now using aggregation, but keep for short transition)
// Only keep last 7 days of raw data for migration purposes, then delete older data
const numericHistoryCutoff = dayjs().subtract(7, "day").utc();
await R.exec("DELETE FROM monitor_numeric_history WHERE time < ?", [R.isoDateTimeMillis(numericHistoryCutoff)]);
await R.exec("DELETE FROM monitor_numeric_history WHERE time < ?", [
R.isoDateTimeMillis(numericHistoryCutoff),
]);
if (Database.dbConfig.type === "sqlite") {
await R.exec("PRAGMA optimize;");

View File

@ -301,7 +301,8 @@ class UptimeCalculator {
minutelyData.minNumeric = numValue;
minutelyData.maxNumeric = numValue;
} else {
minutelyData.avgNumeric = (minutelyData.avgNumeric * (minutelyData.up - 1) + numValue) / minutelyData.up;
minutelyData.avgNumeric =
(minutelyData.avgNumeric * (minutelyData.up - 1) + numValue) / minutelyData.up;
minutelyData.minNumeric = Math.min(minutelyData.minNumeric, numValue);
minutelyData.maxNumeric = Math.max(minutelyData.maxNumeric, numValue);
}
@ -319,7 +320,8 @@ class UptimeCalculator {
hourlyData.minNumeric = numValue;
hourlyData.maxNumeric = numValue;
} else {
hourlyData.avgNumeric = (hourlyData.avgNumeric * (hourlyData.up - 1) + numValue) / hourlyData.up;
hourlyData.avgNumeric =
(hourlyData.avgNumeric * (hourlyData.up - 1) + numValue) / hourlyData.up;
hourlyData.minNumeric = Math.min(hourlyData.minNumeric, numValue);
hourlyData.maxNumeric = Math.max(hourlyData.maxNumeric, numValue);
}
@ -378,7 +380,8 @@ class UptimeCalculator {
dailyStatBean.numeric_max = dailyData.maxNumeric;
{
// eslint-disable-next-line no-unused-vars
const { up, down, avgPing, minPing, maxPing, avgNumeric, minNumeric, maxNumeric, timestamp, ...extras } = dailyData;
const { up, down, avgPing, minPing, maxPing, avgNumeric, minNumeric, maxNumeric, timestamp, ...extras } =
dailyData;
if (Object.keys(extras).length > 0) {
dailyStatBean.extras = JSON.stringify(extras);
}
@ -401,7 +404,18 @@ class UptimeCalculator {
hourlyStatBean.numeric_max = hourlyData.maxNumeric;
{
// eslint-disable-next-line no-unused-vars
const { up, down, avgPing, minPing, maxPing, avgNumeric, minNumeric, maxNumeric, timestamp, ...extras } = hourlyData;
const {
up,
down,
avgPing,
minPing,
maxPing,
avgNumeric,
minNumeric,
maxNumeric,
timestamp,
...extras
} = hourlyData;
if (Object.keys(extras).length > 0) {
hourlyStatBean.extras = JSON.stringify(extras);
}
@ -423,7 +437,18 @@ class UptimeCalculator {
minutelyStatBean.numeric_max = minutelyData.maxNumeric;
{
// eslint-disable-next-line no-unused-vars
const { up, down, avgPing, minPing, maxPing, avgNumeric, minNumeric, maxNumeric, timestamp, ...extras } = minutelyData;
const {
up,
down,
avgPing,
minPing,
maxPing,
avgNumeric,
minNumeric,
maxNumeric,
timestamp,
...extras
} = minutelyData;
if (Object.keys(extras).length > 0) {
minutelyStatBean.extras = JSON.stringify(extras);
}