Skip to content

Commit

Permalink
Merge pull request #102 from Synthetixio/transformers/lint-all-models
Browse files Browse the repository at this point in the history
Transformers - Lint Models
  • Loading branch information
marcus-snx authored Aug 27, 2024
2 parents a1806a4 + 1edd696 commit b652ada
Show file tree
Hide file tree
Showing 193 changed files with 8,142 additions and 7,171 deletions.
6 changes: 5 additions & 1 deletion transformers/synthetix/.sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ignore = templating
runaway_limit = 10
max_line_length = 80
indent_unit = space
exclude_rules = ST06, ST05

[sqlfluff:indentation]
tab_space_size = 4
Expand Down Expand Up @@ -34,4 +35,7 @@ capitalisation_policy = lower
capitalisation_policy = lower

[sqlfluff:rules:ambiguous.column_references] # Number in group by
group_by_and_order_by_style = implicit
group_by_and_order_by_style = explicit

[sqlfluff:rules:references:quoting]
prefer_quoted_keywords = True
1 change: 1 addition & 0 deletions transformers/synthetix/.sqlfluffignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target/
dbt_modules/
dbt_packages/
macros/
templates/
4 changes: 2 additions & 2 deletions transformers/synthetix/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ models:
+tags: "arbitrum_sepolia"
+schema: raw_arbitrum_sepolia
optimism:
+enabled: "{{ target.name == 'prod-op' }}"
+enabled: "{{ target.name == 'prod-op' or target.name == 'dev' }}"
mainnet:
+tags: "optimism_mainnet"
+schema: raw_optimism_mainnet
Expand Down Expand Up @@ -169,7 +169,7 @@ models:
+tags: "arbitrum_sepolia"
+schema: arbitrum_sepolia
optimism:
+enabled: "{{ target.name == 'prod-op' }}"
+enabled: "{{ target.name == 'prod-op' or target.name == 'dev' }}"
mainnet:
+tags: "optimism_mainnet"
+schema: optimism_mainnet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,60 @@
WITH delegation_changes AS (
SELECT
with delegation_changes as (
select
block_timestamp,
account_id,
pool_id,
collateral_type,
{{ convert_wei('amount') }} - LAG({{ convert_wei('amount') }}, 1, 0) over (
PARTITION BY account_id,
pool_id,
collateral_type
ORDER BY
{{ convert_wei('amount') }}
- LAG({{ convert_wei('amount') }}, 1, 0) over (
partition by
account_id,
pool_id,
collateral_type
order by
block_timestamp
) AS change_in_amount
FROM
) as change_in_amount
from
{{ ref('core_delegation_updated_arbitrum_mainnet') }}
),
cumulative_delegation AS (
SELECT

cumulative_delegation as (
select
block_timestamp,
account_id,
pool_id,
collateral_type,
SUM(change_in_amount) over (
PARTITION BY pool_id,
account_id,
collateral_type
ORDER BY
partition by
pool_id,
account_id,
collateral_type
order by
block_timestamp
) AS cumulative_amount_delegated,
) as cumulative_amount_delegated,
ROW_NUMBER() over (
PARTITION BY pool_id,
account_id,
collateral_type
ORDER BY
block_timestamp DESC
) AS rn
FROM
partition by
pool_id,
account_id,
collateral_type
order by
block_timestamp desc
) as rn
from
delegation_changes
)
SELECT
block_timestamp AS ts,
CAST(
account_id AS text
) AS account_id,

select
block_timestamp as ts,
pool_id,
collateral_type,
cumulative_amount_delegated AS amount_delegated
FROM
cumulative_amount_delegated as amount_delegated,
CAST(
account_id as text
) as account_id
from
cumulative_delegation
WHERE
where
rn = 1
ORDER BY
order by
block_timestamp,
collateral_type
Loading

0 comments on commit b652ada

Please sign in to comment.