Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universe events stats handle universe identity proof type #561

Merged
merged 6 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 2 additions & 3 deletions tapdb/sqlc/migrations/000007_universe.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ CREATE VIEW universe_stats AS
COUNT(CASE WHEN u.event_type = 'SYNC' THEN 1 ELSE NULL END) AS total_asset_syncs,
COUNT(CASE WHEN u.event_type = 'NEW_PROOF' THEN 1 ELSE NULL END) AS total_asset_proofs,
roots.asset_id,
roots.group_key,
roots.namespace_root
Roasbeef marked this conversation as resolved.
Show resolved Hide resolved
roots.group_key
FROM universe_events u
JOIN universe_roots roots ON u.universe_root_id = roots.id
GROUP BY roots.asset_id, roots.group_key, roots.namespace_root;
GROUP BY roots.asset_id, roots.group_key;

-- This table contains global configuration for universe federation syncing.
CREATE TABLE IF NOT EXISTS federation_global_sync_config (
Expand Down
1 change: 0 additions & 1 deletion tapdb/sqlc/models.go

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

18 changes: 13 additions & 5 deletions tapdb/sqlc/queries/universe.sql
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,18 @@ SELECT * FROM universe_servers;
-- name: InsertNewSyncEvent :exec
WITH group_key_root_id AS (
SELECT id
FROM universe_roots
FROM universe_roots roots
WHERE group_key = @group_key_x_only
AND roots.proof_type = @proof_type
), asset_id_root_id AS (
SELECT leaves.universe_root_id AS id
FROM universe_leaves leaves
JOIN universe_roots roots
ffranr marked this conversation as resolved.
Show resolved Hide resolved
ON leaves.universe_root_id = roots.id
JOIN genesis_info_view gen
ON leaves.asset_genesis_id = gen.gen_asset_id
WHERE gen.asset_id = @asset_id
WHERE gen.asset_id = @asset_id
AND roots.proof_type = @proof_type
LIMIT 1
)
INSERT INTO universe_events (
Expand All @@ -138,14 +142,18 @@ INSERT INTO universe_events (
-- name: InsertNewProofEvent :exec
WITH group_key_root_id AS (
SELECT id
FROM universe_roots
FROM universe_roots roots
WHERE group_key = @group_key_x_only
AND roots.proof_type = @proof_type
), asset_id_root_id AS (
SELECT leaves.universe_root_id AS id
FROM universe_leaves leaves
JOIN genesis_info_view gen
ON leaves.asset_genesis_id = gen.gen_asset_id
JOIN universe_roots roots
ON leaves.universe_root_id = roots.id
JOIN genesis_info_view gen
ON leaves.asset_genesis_id = gen.gen_asset_id
Roasbeef marked this conversation as resolved.
Show resolved Hide resolved
WHERE gen.asset_id = @asset_id
AND roots.proof_type = @proof_type
LIMIT 1
)
INSERT INTO universe_events (
Expand Down
24 changes: 18 additions & 6 deletions tapdb/sqlc/universe.sql.go

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

4 changes: 4 additions & 0 deletions tapdb/universe_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func (u *UniverseStats) LogSyncEvent(ctx context.Context,
EventTimestamp: u.clock.Now().UTC().Unix(),
AssetID: uniID.AssetID[:],
GroupKeyXOnly: groupKeyXOnly,
ProofType: uniID.ProofType.String(),
ffranr marked this conversation as resolved.
Show resolved Hide resolved
})
})
}
Expand All @@ -165,6 +166,7 @@ func (u *UniverseStats) LogSyncEvents(ctx context.Context,
EventTimestamp: u.clock.Now().UTC().Unix(),
AssetID: uniID.AssetID[:],
GroupKeyXOnly: groupKeyXOnly,
ProofType: uniID.ProofType.String(),
})
if err != nil {
return err
Expand All @@ -191,6 +193,7 @@ func (u *UniverseStats) LogNewProofEvent(ctx context.Context,
EventTimestamp: u.clock.Now().UTC().Unix(),
AssetID: uniID.AssetID[:],
GroupKeyXOnly: groupKeyXOnly,
ProofType: uniID.ProofType.String(),
})
})
}
Expand All @@ -215,6 +218,7 @@ func (u *UniverseStats) LogNewProofEvents(ctx context.Context,
EventTimestamp: u.clock.Now().UTC().Unix(),
AssetID: uniID.AssetID[:],
GroupKeyXOnly: groupKeyXOnly,
ProofType: uniID.ProofType.String(),
})
if err != nil {
return err
Expand Down