Skip to content

Commit

Permalink
feat: 🎨 iterate assets and resources (#62)
Browse files Browse the repository at this point in the history
* feat: 🎨 iterate assets and resources

* feat: ⚡️ new allo models

* fix: 📝 update paths

* chore: 🩹 fix catalog

* feat: 🦺 add retrying logic
  • Loading branch information
davidgasquez authored Feb 21, 2024
1 parent 831819a commit 65a246e
Show file tree
Hide file tree
Showing 27 changed files with 3,459 additions and 3,563 deletions.
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
.DEFAULT_GOAL := run

run:
@dagster job execute -j data_assets_job -m ggdp

apis:
@dagster job execute -j private_apis_assets_job -m ggdp
@dagster asset materialize --select \* -m ggdp

tables:
@python -c 'from ggdp import db; db.export_database_to_parquet("data/local.duckdb", "data/tables");'
Expand Down Expand Up @@ -35,5 +32,5 @@ publish:
@quarto publish gh-pages portal --no-prompt

clean:
@rm -rf portal/.quarto data/*.parquet data/*.duckdb portal/_site
@rm -rf portal/.quarto data/*.parquet data/*.duckdb portal/_site data/tables
@rm -rf dbt/target dbt/logs dbt/dbt_packages
29 changes: 29 additions & 0 deletions dbt/models/allo_applications.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
with source as (
select * from {{ source('public', 'raw_allo_applications') }}
),

renamed as (
select
anchorAddress as anchor_address,
lower(chainId) as chain_id,
createdAtBlock as created_at_block,
createdByAddress as created_by_address,
lower(id) as id,
metadata,
metadata->>'$.signature' as metadata_signature,
lower(metadata->>'$.application.recipient') as metadata_application_recipient,
metadataCid as metadata_cid,
nodeId as node_id,
lower(projectId) as project_id,
lower(roundId) as round_id,
status,
statusSnapshots as status_snapshots,
statusUpdatedAtBlock as status_updated_at_block,
tags,
totalAmountDonatedInUsd as total_amount_donated_in_usd,
totalDonationsCount as total_donations_count,
uniqueDonorsCount as unique_donors_count
from source
)

select * from renamed
13 changes: 13 additions & 0 deletions dbt/models/allo_deployments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
with source as (
select * from {{ source('public', 'raw_allo_deployments') }}
),

renamed as (
select
lower(address) as address,
chain_name,
contract
from source
)

select * from renamed
24 changes: 24 additions & 0 deletions dbt/models/allo_donations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
with source as (
select * from {{ source('public', 'raw_allo_donations') }}
),

renamed as (
select
amountInUsd as amount_in_usd,
amount,
amountInRoundMatchToken as amount_in_round_match_token,
applicationId as application_id,
blockNumber as block_number,
chainId as chain_id,
lower(id) as id,
lower(donorAddress) as donor_address,
nodeId as node_id,
lower(projectId) as project_id,
lower(recipientAddress) as recipient_address,
lower(roundId) as round_id,
lower(tokenAddress) as token_address,
lower(transactionHash) as transaction_hash,
from source
)

select * from renamed
17 changes: 17 additions & 0 deletions dbt/models/allo_prices.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
with source as (
select * from {{ source('public', 'raw_allo_prices') }}
),

renamed as (
select
blockNumber as block_number,
lower(chainId) as chain_id,
id,
nodeId as node_id,
priceInUsd as price_in_usd,
timestamp,
lower(tokenAddress) as token_address,
from source
)

select * from renamed
34 changes: 34 additions & 0 deletions dbt/models/allo_projects.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
with source as (
select * from {{ source('public', 'raw_allo_projects') }}
),

renamed as (
select
anchorAddress as anchor_address,
chainId as chain_id,
createdAtBlock as created_at_block,
lower(createdByAddress) as created_by_address,
id,
metadata as metadata,
metadata->>'title' as title,
metadata->>'description' as description,
metadata->>'website' as website,
metadata->>'projectTwitter' as project_twitter,
metadata->>'projectGithub' as project_github,
metadata->>'userGithub' as user_github,
metadata->>'logoImg' as logo_image,
metadata->>'bannerImg' as banner_image,
cast(metadata->>'createdAt' as numeric) as created_at,
metadataCid as metadata_cid,
name as name,
nodeId as node_id,
nonce,
projectNumber as project_number,
projectType as project_type,
registryAddress as registry_address,
tags,
updatedAtBlock as updated_at_block
from source
)

select * from renamed
42 changes: 42 additions & 0 deletions dbt/models/allo_rounds.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
with source as (
select * from {{ source('public', 'raw_allo_rounds') }}
),

renamed as (
select
adminRole as admin_role,
applicationMetadata as application_metadata,
applicationMetadataCid as application_metadata_cid,
applicationsEndTime as applications_end_time,
applicationsStartTime as applications_start_time,
chainId as chain_id,
createdAtBlock as created_at_block,
createdByAddress as created_by_address,
donationsEndTime as donations_end_time,
donationsStartTime as donations_start_time,
lower(id) as id,
isReadyForPayout as is_ready_for_payout,
managerRole as manager_role,
matchAmount as match_amount,
matchAmountInUsd as match_amount_in_usd,
matchTokenAddress as match_token_address,
nodeId as node_id,
lower(projectId) as project_id,
roundMetadata as round_metadata,
roundMetadataCid as round_metadata_cid,
roundMetadata->>'$.name' as round_metadata_name,
roundMetadata->>'$.roundType' as round_metadata_round_type,
lower(roundMetadata->>'$.programContractAddress') as round_metadata_program_address,
roundMetadata->>'$.quadraticFundingConfig.sybilDefense' as round_metadata_sybil_defense,
strategyAddress as strategy_address,
strategyId as strategy_id,
strategyName as strategy_name,
tags,
totalAmountDonatedInUsd as total_amount_donated_in_usd,
totalDonationsCount as total_donations_count,
uniqueDonorsCount as unique_donors_count,
updatedAtBlock as updated_at_block
from source
)

select * from renamed
21 changes: 21 additions & 0 deletions dbt/models/allo_subscriptions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
with source as (
select * from {{ source('public', 'raw_allo_subscriptions') }}
),

renamed as (
select
chainId as chain_id,
lower(contractAddress) as contract_address,
contractName as contract_name,
createdAt as created_at,
fromBlock as from_block,
id,
indexedToBlock as indexed_to_block,
indexedToLogIndex as indexed_to_log_index,
nodeId as node_id,
toBlock as to_block,
updatedAt as updated_at
from source
)

select * from renamed
58 changes: 32 additions & 26 deletions dbt/models/application_answers.sql
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
with source as (
select metadata, chainid, roundid, projectid, id from {{ source("public", "raw_round_applications") }}
),
with source as (
select
metadata,
chainid,
roundid,
projectid,
id
from {{ source("public", "raw_allo_applications") }}
),

renamed as (
select
unnest(
from_json(json_extract_path_text(source.metadata, '$.application.answers'), '["json"]')
) as row_json,
chainid as chain_id,
roundid as round_id,
id as application_id,
projectid as project_id
from source
),
renamed as (
select
unnest(
from_json(json_extract_path_text(source.metadata, '$.application.answers'), '["json"]')
) as row_json,
chainid as chain_id,
roundid as round_id,
id as application_id,
projectid as project_id
from source
),

extracted as (
select
json_extract_path_text(row_json, 'questionId') as question_id,
project_id,
application_id,
chain_id,
lower(round_id) as round_id,
json_extract_path_text(row_json, 'question') as question,
json_extract_path_text(row_json, 'type') as question_type,
json_extract_path_text(row_json, 'answer') as answer
from renamed
)
extracted as (
select
json_extract_path_text(row_json, 'questionId') as question_id,
project_id,
application_id,
chain_id,
lower(round_id) as round_id,
json_extract_path_text(row_json, 'question') as question,
json_extract_path_text(row_json, 'type') as question_type,
json_extract_path_text(row_json, 'answer') as answer
from renamed
)

select * from extracted where answer is not null -- filters out encrypted and skipped answers
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
with source as (
select * from {{ source('public', 'raw_passport_scores') }}
select * from {{ source('public', 'raw_gitcoin_passport_scores') }}
),

renamed as (
Expand Down
32 changes: 0 additions & 32 deletions dbt/models/projects.sql

This file was deleted.

30 changes: 0 additions & 30 deletions dbt/models/round_applications.sql

This file was deleted.

23 changes: 0 additions & 23 deletions dbt/models/round_votes.sql

This file was deleted.

Loading

0 comments on commit 65a246e

Please sign in to comment.