Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 22 additions & 52 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
wasm-pack
trunk
nodejs
nodePackages.tailwindcss
tailwindcss
];
};
targets = (pkgs.lib.getAttrs
Expand Down Expand Up @@ -130,7 +130,7 @@
wasm-pack
nodejs
binaryen
nodePackages.tailwindcss
tailwindcss
];

FMO_API_SERVER = api;
Expand Down
34 changes: 34 additions & 0 deletions fmo_server/schema/v9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- Optimize latest_guardian_health to avoid aggregating all historical health rows.
BEGIN;

INSERT INTO schema_version (version)
VALUES (9);

CREATE OR REPLACE VIEW latest_guardian_health AS
SELECT
gh.federation_id,
gh.time,
gh.guardian_id,
gh.status,
gh.block_height,
gh.latency_ms
FROM
federations f
CROSS JOIN LATERAL (
SELECT
time
FROM
guardian_health
WHERE
federation_id = f.federation_id
ORDER BY
time DESC
LIMIT 1
) latest
INNER JOIN
guardian_health gh
ON
gh.federation_id = f.federation_id
AND gh.time = latest.time;

COMMIT;
1 change: 1 addition & 0 deletions fmo_server/src/federation/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ impl FederationObserver {
"/schema/v8.sql",
FederationObserver::backfill_reprocess_all_sessions
),
migration!("/schema/v9.sql"),
];

for (index, migration) in migrations.iter().enumerate() {
Expand Down
Loading