diff --git a/machines/status01/unethical_patch_0.patch b/machines/status01/unethical_patch_0.patch new file mode 100644 index 0000000..fd4876c --- /dev/null +++ b/machines/status01/unethical_patch_0.patch @@ -0,0 +1,30 @@ +diff --git a/server/model/group.js b/server/model/group.js +index 5b712ace..ecbced1a 100644 +--- a/server/model/group.js ++++ b/server/model/group.js +@@ -31,10 +31,23 @@ class Group extends BeanModel { + */ + async getMonitorList() { + return R.convertToBeans("monitor", await R.getAll(` +- SELECT monitor.*, monitor_group.send_url FROM monitor, monitor_group +- WHERE monitor.id = monitor_group.monitor_id ++ SELECT monitor.*, monitor_group.send_url ++ FROM monitor ++ INNER JOIN monitor_group ON monitor.id = monitor_group.monitor_id ++ WHERE monitor.id IN ( ++ SELECT hb.monitor_id ++ FROM heartbeat hb ++ INNER JOIN ( ++ SELECT monitor_id, MAX(time) AS latest_time ++ FROM heartbeat ++ GROUP BY monitor_id ++ ) latest_hb ++ ON hb.monitor_id = latest_hb.monitor_id AND hb.time = latest_hb.latest_time ++ WHERE hb.status = 1 ++ ) + AND group_id = ? + ORDER BY monitor_group.weight ++ + `, [ + this.id, + ])); diff --git a/machines/status01/uptime-kuma.nix b/machines/status01/uptime-kuma.nix index f531fd8..4f4331f 100644 --- a/machines/status01/uptime-kuma.nix +++ b/machines/status01/uptime-kuma.nix @@ -3,6 +3,7 @@ lib, nodes, sources, + pkgs, ... }: let @@ -100,7 +101,17 @@ in imports = [ (sources.stateless-uptime-kuma + "/nixos/module.nix") ]; nixpkgs.overlays = [ (import (sources.stateless-uptime-kuma + "/overlay.nix")) ]; - services.uptime-kuma.enable = true; + services.uptime-kuma = { + enable = true; + package = pkgs.uptime-kuma.overrideAttrs ( + _: prev: { + patches = prev.patches ++ [ + # Very important patch + ./unethical_patch_0.patch + ]; + } + ); + }; services.nginx = { enable = true;