-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dbt): gitcoin models to include round uids (#2577)
- Loading branch information
Showing
7 changed files
with
113 additions
and
61 deletions.
There are no files selected for viewing
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
51 changes: 15 additions & 36 deletions
51
warehouse/dbt/models/intermediate/funding/int_gitcoin_funding_rounds.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 |
---|---|---|
@@ -1,42 +1,21 @@ | ||
with partner_rounds as ( | ||
select * | ||
from {{ ref('int_gitcoin_funding_events') }} | ||
where | ||
round_type = 'PartnerRound' | ||
and round_name is not null | ||
), | ||
|
||
main_rounds as ( | ||
select * | ||
from {{ ref('int_gitcoin_funding_events') }} | ||
where round_type = 'MainRound' | ||
), | ||
|
||
unioned as ( | ||
select * from partner_rounds | ||
union all | ||
select * from main_rounds | ||
) | ||
|
||
select | ||
gitcoin_data_source, | ||
gitcoin_round_id, | ||
round_number, | ||
round_name, | ||
oso_generated_round_label, | ||
round_type, | ||
main_round_label, | ||
array_agg(distinct chain_id) as chain_ids, | ||
sum(amount_in_usd) as total_amount_in_usd, | ||
count(distinct gitcoin_project_id) as count_projects | ||
from unioned | ||
min(event_time) as first_event_time, | ||
max(event_time) as last_event_time, | ||
count(distinct gitcoin_project_id) as count_projects, | ||
count(distinct donor_address) as unique_donors, | ||
sum( | ||
case | ||
when gitcoin_data_source = 'MatchFunding' then amount_in_usd | ||
else 0 | ||
end | ||
) as match_funding_amount_in_usd, | ||
sum(amount_in_usd) as total_funding_amount_in_usd | ||
from {{ ref('int_gitcoin_funding_events') }} | ||
group by | ||
gitcoin_data_source, | ||
gitcoin_round_id, | ||
round_number, | ||
round_name, | ||
oso_generated_round_label, | ||
round_type, | ||
main_round_label | ||
order by | ||
round_type asc, | ||
main_round_label desc, | ||
gitcoin_round_id asc | ||
order by oso_generated_round_label |
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
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
11 changes: 11 additions & 0 deletions
11
warehouse/dbt/models/marts/gitcoin/gitcoin_funding_rounds_v0.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,11 @@ | ||
select | ||
oso_generated_round_label, | ||
round_type, | ||
main_round_label, | ||
count_projects, | ||
unique_donors, | ||
match_funding_amount_in_usd, | ||
total_funding_amount_in_usd, | ||
first_event_time, | ||
last_event_time | ||
from {{ ref('int_gitcoin_funding_rounds') }} |
10 changes: 10 additions & 0 deletions
10
warehouse/dbt/models/marts/gitcoin/gitcoin_project_directory_v0.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,10 @@ | ||
select distinct | ||
gitcoin_project_id, | ||
latest_project_github, | ||
latest_project_recipient_address, | ||
oso_wallet_match, | ||
oso_repo_match, | ||
oso_project_id, | ||
oso_project_name, | ||
oso_display_name | ||
from {{ ref('int_gitcoin_project_directory') }} |