Skip to content

Commit

Permalink
AN-4936/Backfill Migration Final (#335)
Browse files Browse the repository at this point in the history
* del cw models

* core views

* defi views

* gov view

* nft_views

* rm ref to old cw models

* del internal cols

* nv 13-15

* nv 13-15

* nv 17-18

* nv 20

* del temp logic

* upd tests on allday metadata

* upd to warn
  • Loading branch information
forgxyz authored Jul 1, 2024
1 parent 3bf75df commit 30ce62f
Show file tree
Hide file tree
Showing 83 changed files with 120 additions and 6,664 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dbt_run_scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: >
dbt run-operation stage_external_sources --vars "ext_full_refresh: true";
dbt seed;
dbt run -s tag:scheduled_core tag:streamline_complete "flow_models,models/gold" --vars '{"STREAMLINE_START_BLOCK": ${{ vars.STREAMLINE_START_BLOCK }}}'
dbt run -s tag:scheduled_core tag:streamline_complete "flow_models,models/gold"
- name: Store logs
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dbt_run_scheduled_non_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: >
dbt run-operation stage_external_sources --vars "ext_full_refresh: true";
dbt seed;
dbt run -s tag:scheduled_non_core --vars '{"STREAMLINE_START_BLOCK": ${{ vars.STREAMLINE_START_BLOCK }}}'
dbt run -s tag:scheduled_non_core
- name: Store logs
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: "flow_models"
version: "1.7.0"
version: "1.8.0"
config-version: 2

require-dbt-version: ">=1.7.0"
Expand Down
55 changes: 5 additions & 50 deletions models/gold/core/core__dim_contract_labels.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,16 @@
tags = ['scheduled']
) }}

WITH chainwalkers AS (

SELECT
NULL AS event_contract_id,
event_contract,
contract_name,
account_address,
_inserted_timestamp,
NULL AS inserted_timestamp,
NULL AS modified_timestamp
FROM
{{ ref('silver__contract_labels') }}
),
streamline AS (
SELECT
event_contract_id,
event_contract,
contract_name,
account_address,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__contract_labels_s') }}
),
FINAL AS (
SELECT
*
FROM
chainwalkers
UNION ALL
SELECT
*
FROM
streamline
)
SELECT
event_contract_id,
event_contract,
contract_name,
account_address,
inserted_timestamp,
modified_timestamp,
COALESCE (
event_contract_id,
{{ dbt_utils.generate_surrogate_key(['event_contract']) }}
) AS dim_contract_labels_id,
COALESCE (
inserted_timestamp,
_inserted_timestamp
) AS inserted_timestamp,
COALESCE (
modified_timestamp,
_inserted_timestamp
) AS modified_timestamp
) AS dim_contract_labels_id
FROM
FINAL qualify ROW_NUMBER() over (
PARTITION BY event_contract
ORDER BY
_inserted_timestamp DESC
) = 1
{{ ref('silver__contract_labels_s') }}
79 changes: 8 additions & 71 deletions models/gold/core/core__ez_token_transfers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,6 @@
tags = ['ez', 'scheduled']
) }}

WITH chainwalkers AS (

SELECT
NULL AS token_transfers_id,
block_height,
block_timestamp,
tx_id,
sender,
recipient,
token_contract,
amount,
tx_succeeded,
_inserted_timestamp,
NULL AS inserted_timestamp,
NULL AS modified_timestamp
FROM
{{ ref('silver__token_transfers') }}
WHERE
token_contract NOT IN (
'A.c38aea683c0c4d38.ZelosAccountingToken',
'A.f1b97c06745f37ad.SwapPair'
)
AND block_height < {{ var(
'STREAMLINE_START_BLOCK'
) }}
),
streamline AS (
SELECT
token_transfers_id,
block_height,
block_timestamp,
tx_id,
sender,
recipient,
token_contract,
amount,
tx_succeeded,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__token_transfers_s') }}
WHERE
token_contract NOT IN (
'A.c38aea683c0c4d38.ZelosAccountingToken',
'A.f1b97c06745f37ad.SwapPair'
)
AND block_height >= {{ var(
'STREAMLINE_START_BLOCK'
) }}
),
FINAL AS (
SELECT
*
FROM
streamline
UNION ALL
SELECT
*
FROM
chainwalkers
)
SELECT
block_height,
block_timestamp,
Expand All @@ -80,13 +18,12 @@ SELECT
['tx_id','sender', 'recipient','token_contract', 'amount']
) }}
) AS ez_token_transfers_id,
COALESCE (
inserted_timestamp,
_inserted_timestamp
) AS inserted_timestamp,
COALESCE (
modified_timestamp,
_inserted_timestamp
) AS modified_timestamp
inserted_timestamp,
modified_timestamp
FROM
FINAL
{{ ref('silver__token_transfers_s') }}
WHERE
token_contract NOT IN (
'A.c38aea683c0c4d38.ZelosAccountingToken',
'A.f1b97c06745f37ad.SwapPair'
)
1 change: 0 additions & 1 deletion models/gold/core/core__ez_token_transfers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ models:
- amount
config:
severity: warn
error_if: ">10"

columns:
- name: TX_ID
Expand Down
74 changes: 7 additions & 67 deletions models/gold/core/core__fact_blocks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,21 @@
tags = ['scheduled']
) }}

WITH chainwalkers AS (

SELECT
NULL AS blocks_id,
block_height,
block_timestamp,
network,
network_version,
chain_id,
tx_count,
id,
parent_id,
_inserted_timestamp,
NULL AS inserted_timestamp,
NULL AS modified_timestamp
FROM
{{ ref('silver__blocks') }}
WHERE
block_height < {{ var(
'STREAMLINE_START_BLOCK'
) }}
),
streamline AS (
SELECT
blocks_id,
block_height,
block_timestamp,
'mainnet' AS network,
network_version,
'flow' AS chain_id,
tx_count,
id,
parent_id,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__streamline_blocks') }}
WHERE
block_height >= {{ var(
'STREAMLINE_START_BLOCK'
) }}
),
FINAL AS (
SELECT
*
FROM
chainwalkers
UNION ALL
SELECT
*
FROM
streamline
)
SELECT
blocks_id,
block_height,
block_height :: INT AS block_height,
block_timestamp,
network,
'mainnet' AS network,
network_version,
chain_id,
'flow' AS chain_id,
tx_count,
id,
parent_id,
COALESCE (
blocks_id,
{{ dbt_utils.generate_surrogate_key(['block_height']) }}
) AS fact_blocks_id,
COALESCE (
inserted_timestamp,
_inserted_timestamp
) AS inserted_timestamp,
COALESCE (
modified_timestamp,
_inserted_timestamp
) AS modified_timestamp
_inserted_timestamp,
inserted_timestamp,
modified_timestamp
FROM
FINAL
{{ ref('silver__streamline_blocks') }}
69 changes: 5 additions & 64 deletions models/gold/core/core__fact_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,10 @@
tags = ['scheduled']
) }}

WITH chainwalkers AS (

SELECT
NULL AS streamline_event_id,
tx_id,
block_timestamp,
block_height,
tx_succeeded,
event_index,
event_contract,
event_type,
event_data,
_inserted_timestamp,
NULL AS inserted_timestamp,
NULL AS modified_timestamp
FROM
{{ ref('silver__events_final') }}
WHERE
block_height < {{ var(
'STREAMLINE_START_BLOCK'
) }}
),
streamline AS (
SELECT
streamline_event_id,
tx_id,
block_timestamp,
block_height,
tx_succeeded,
event_index,
event_contract,
event_type,
event_data,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__streamline_events') }}
WHERE
block_height >= {{ var(
'STREAMLINE_START_BLOCK'
) }}
),
FINAL AS (
SELECT
*
FROM
chainwalkers
UNION ALL
SELECT
*
FROM
streamline
)
SELECT
tx_id,
block_timestamp,
block_height,
block_height :: INT AS block_height,
tx_succeeded,
event_index,
event_contract,
Expand All @@ -70,13 +16,8 @@ SELECT
streamline_event_id,
{{ dbt_utils.generate_surrogate_key(['tx_id']) }}
) AS fact_events_id,
COALESCE (
inserted_timestamp,
_inserted_timestamp
) AS inserted_timestamp,
COALESCE (
modified_timestamp,
_inserted_timestamp
) AS modified_timestamp
_inserted_timestamp,
inserted_timestamp,
modified_timestamp
FROM
FINAL
{{ ref('silver__streamline_events') }}
Loading

0 comments on commit 30ce62f

Please sign in to comment.