Skip to content

Commit

Permalink
Feat: Add stat_hourly & min. max. ping (#4267)
Browse files Browse the repository at this point in the history
Co-authored-by: Frank Elsinga <frank@elsinga.de>
  • Loading branch information
chakflying and CommanderStorm authored Jan 5, 2024
1 parent 0060e46 commit bf1e3a3
Show file tree
Hide file tree
Showing 4 changed files with 383 additions and 54 deletions.
24 changes: 24 additions & 0 deletions db/knex_migrations/2023-12-21-0000-stat-ping-min-max.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
exports.up = function (knex) {
return knex.schema
.alterTable("stat_daily", function (table) {
table.float("ping_min").notNullable().defaultTo(0).comment("Minimum ping during this period in milliseconds");
table.float("ping_max").notNullable().defaultTo(0).comment("Maximum ping during this period in milliseconds");
})
.alterTable("stat_minutely", function (table) {
table.float("ping_min").notNullable().defaultTo(0).comment("Minimum ping during this period in milliseconds");
table.float("ping_max").notNullable().defaultTo(0).comment("Maximum ping during this period in milliseconds");
});

};

exports.down = function (knex) {
return knex.schema
.alterTable("stat_daily", function (table) {
table.dropColumn("ping_min");
table.dropColumn("ping_max");
})
.alterTable("stat_minutely", function (table) {
table.dropColumn("ping_min");
table.dropColumn("ping_max");
});
};
26 changes: 26 additions & 0 deletions db/knex_migrations/2023-12-22-0000-hourly-uptime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
exports.up = function (knex) {
return knex.schema
.createTable("stat_hourly", function (table) {
table.increments("id");
table.comment("This table contains the hourly aggregate statistics for each monitor");
table.integer("monitor_id").unsigned().notNullable()
.references("id").inTable("monitor")
.onDelete("CASCADE")
.onUpdate("CASCADE");
table.integer("timestamp")
.notNullable()
.comment("Unix timestamp rounded down to the nearest hour");
table.float("ping").notNullable().comment("Average ping in milliseconds");
table.float("ping_min").notNullable().defaultTo(0).comment("Minimum ping during this period in milliseconds");
table.float("ping_max").notNullable().defaultTo(0).comment("Maximum ping during this period in milliseconds");
table.smallint("up").notNullable();
table.smallint("down").notNullable();

table.unique([ "monitor_id", "timestamp" ]);
});
};

exports.down = function (knex) {
return knex.schema
.dropTable("stat_hourly");
};
Loading

0 comments on commit bf1e3a3

Please sign in to comment.