-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Yearly and monthly resolutions (#55)
- Loading branch information
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
hasura/metadata/databases/minterop/tables/analytics_tmp_referrer_earnings_monthly.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
table: | ||
schema: analytics_tmp | ||
name: referrer_earnings_monthly | ||
select_permissions: | ||
- role: anonymous | ||
permission: | ||
columns: | ||
- date_trunc | ||
- referrer_id | ||
- sales_count | ||
- total_earned | ||
filter: {} | ||
allow_aggregations: true |
2 changes: 1 addition & 1 deletion
2
...bles/analytics_tmp_referrer_earnings.yaml → ...alytics_tmp_referrer_earnings_yearly.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
migrations/2023-01-20-122717_analytics-earnings-yearly/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
create view analytics_tmp.referrer_earnings as | ||
select | ||
date_trunc, | ||
receiver_id as referrer_id, | ||
sum(amount) as total_earned, | ||
count(*) as sales_count | ||
from ( | ||
select date_trunc('month', timestamp)::date, receiver_id, amount | ||
from nft_earnings | ||
where is_referral = TRUE | ||
and nft_contract_id <> 'deadmau5.mintbase1.near' | ||
) e | ||
group by date_trunc, receiver_id | ||
order by date_trunc, receiver_id | ||
; | ||
|
||
drop view analytics_tmp.referrer_earnings_monthly; | ||
drop view analytics_tmp.referrer_earnings_yearly; |
31 changes: 31 additions & 0 deletions
31
migrations/2023-01-20-122717_analytics-earnings-yearly/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
create view analytics_tmp.referrer_earnings_monthly as | ||
select | ||
date_trunc, | ||
receiver_id as referrer_id, | ||
sum(amount) as total_earned, | ||
count(*) as sales_count | ||
from ( | ||
select date_trunc('month', timestamp)::date, receiver_id, amount | ||
from nft_earnings | ||
where is_referral = TRUE | ||
and nft_contract_id <> 'deadmau5.mintbase1.near' | ||
) e | ||
group by date_trunc, receiver_id | ||
order by date_trunc, receiver_id | ||
; | ||
|
||
create view analytics_tmp.referrer_earnings_yearly as | ||
select | ||
date_trunc, | ||
receiver_id as referrer_id, | ||
sum(amount) as total_earned, | ||
count(*) as sales_count | ||
from ( | ||
select date_trunc('month', timestamp)::date, receiver_id, amount | ||
from nft_earnings | ||
where is_referral = TRUE | ||
and nft_contract_id <> 'deadmau5.mintbase1.near' | ||
) e | ||
group by date_trunc, receiver_id | ||
order by date_trunc, receiver_id | ||
; |