Skip to content

Commit

Permalink
add daily/monthly average tx fee
Browse files Browse the repository at this point in the history
  • Loading branch information
slandymani committed Mar 28, 2024
1 parent 5d5c97a commit 085d0c9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions database/schema/00-cosmos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,18 @@ SELECT DATE_TRUNC('month', b.timestamp) AS month,
COUNT(t.height) AS transaction_volume
FROM block b
LEFT JOIN transaction t ON b.height = t.height
GROUP BY month;

CREATE VIEW daily_average_fee AS
SELECT DATE_TRUNC('day', b.timestamp) AS day,
AVG((fee->'amount'->0->>'amount')::numeric) AS avg_daily_fee
FROM block b
LEFT JOIN transaction t ON b.height = t.height
GROUP BY day;

CREATE VIEW monthly_average_fee AS
SELECT DATE_TRUNC('month', b.timestamp) AS month,
AVG((fee->'amount'->0->>'amount')::numeric) AS avg_monthly_fee
FROM block b
LEFT JOIN transaction t ON b.height = t.height
GROUP BY month;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
table:
name: daily_average_fee
schema: public
select_permissions:
- permission:
allow_aggregations: true
columns:
- day
- avg_daily_fee
filter: {}
limit: 100
role: anonymous
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
table:
name: monthly_average_fee
schema: public
select_permissions:
- permission:
allow_aggregations: true
columns:
- month
- avg_monthly_fee
filter: {}
limit: 100
role: anonymous

0 comments on commit 085d0c9

Please sign in to comment.