Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-snx committed Oct 29, 2024
1 parent 78b0f30 commit ad9366e
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,35 @@ with active_accounts as (
),

date_range as (
select generate_series(
date(min(activity_date)),
date(max(activity_date)),
interval '1 day'
)::date as activity_date
from active_accounts
select
generate_series(
date(min(activity_date)),
date(max(activity_date)),
interval '1 day'
)::date as activity_date
from active_accounts
),

active_accounts_daily as (
select
date_range.activity_date,
count(distinct account_id) as active_accounts
from date_range
left join active_accounts using(activity_date)
group by date_range.activity_date
select
date_range.activity_date,
count(distinct active_accounts.account_id) as active_accounts
from date_range
left join active_accounts
on date_range.activity_date = active_accounts.activity_date
group by date_range.activity_date
),

active_accounts_monthly as (
select
select
date_range.activity_date,
count(distinct active_accounts.account_id) as active_accounts
from date_range
left join active_accounts
on active_accounts.activity_date >= date_range.activity_date - interval '27 days'
and active_accounts.activity_date <= date_range.activity_date
left join active_accounts
on
date_range.activity_date - interval '27 days'
<= active_accounts.activity_date
and date_range.activity_date >= active_accounts.activity_date
group by date_range.activity_date
),

Expand All @@ -45,40 +49,41 @@ new_accounts as (
account_id
from active_accounts
group by account_id
),
),

new_accounts_daily as (
select
activity_date,
count(account_id) as new_accounts
date_range.activity_date,
count(new_accounts.account_id) as new_accounts
from date_range
left join new_accounts on activity_date = start_date
group by activity_date, start_date
left join new_accounts
on date_range.activity_date = new_accounts.start_date
group by date_range.activity_date, new_accounts.start_date
),

new_accounts_monthly as (
select distinct
activity_date,
sum(new_accounts) over (
order by activity_date
range between interval '27 days' preceding and current row
) as new_accounts
from new_accounts_daily
activity_date,
sum(new_accounts) over (
order by activity_date
range between interval '27 days' preceding and current row
) as new_accounts
from new_accounts_daily
)

select
dr.activity_date as date,
dr.activity_date,
dau.active_accounts as dau,
mau.active_accounts as mau,
new_accounts_daily.new_accounts as new_accounts_daily,
new_accounts_monthly.new_accounts as new_accounts_monthly
from date_range as dr
left join active_accounts_daily as dau
on dr.activity_date = dau.activity_date
on dr.activity_date = dau.activity_date
left join active_accounts_monthly as mau
on dr.activity_date = mau.activity_date
left join new_accounts_daily
on dr.activity_date = new_accounts_daily.activity_date
left join new_accounts_monthly
on dr.activity_date = new_accounts_monthly.activity_date
order by date desc
order by activity_date desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
models:
- name: fct_perp_account_activity_arbitrum_mainnet
columns:
- name: date
- name: activity_date
description: "Activity date"
data_type: date
tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,35 @@ with active_accounts as (
),

date_range as (
select generate_series(
date(min(activity_date)),
date(max(activity_date)),
interval '1 day'
)::date as activity_date
from active_accounts
select
generate_series(
date(min(activity_date)),
date(max(activity_date)),
interval '1 day'
)::date as activity_date
from active_accounts
),

active_accounts_daily as (
select
date_range.activity_date,
count(distinct account_id) as active_accounts
from date_range
left join active_accounts using(activity_date)
group by date_range.activity_date
select
date_range.activity_date,
count(distinct active_accounts.account_id) as active_accounts
from date_range
left join active_accounts
on date_range.activity_date = active_accounts.activity_date
group by date_range.activity_date
),

active_accounts_monthly as (
select
select
date_range.activity_date,
count(distinct active_accounts.account_id) as active_accounts
from date_range
left join active_accounts
on active_accounts.activity_date >= date_range.activity_date - interval '27 days'
and active_accounts.activity_date <= date_range.activity_date
left join active_accounts
on
date_range.activity_date - interval '27 days'
<= active_accounts.activity_date
and date_range.activity_date >= active_accounts.activity_date
group by date_range.activity_date
),

Expand All @@ -45,40 +49,41 @@ new_accounts as (
account_id
from active_accounts
group by account_id
),
),

new_accounts_daily as (
select
activity_date,
count(account_id) as new_accounts
date_range.activity_date,
count(new_accounts.account_id) as new_accounts
from date_range
left join new_accounts on activity_date = start_date
group by activity_date, start_date
left join new_accounts
on date_range.activity_date = new_accounts.start_date
group by date_range.activity_date, new_accounts.start_date
),

new_accounts_monthly as (
select distinct
activity_date,
sum(new_accounts) over (
order by activity_date
range between interval '27 days' preceding and current row
) as new_accounts
from new_accounts_daily
activity_date,
sum(new_accounts) over (
order by activity_date
range between interval '27 days' preceding and current row
) as new_accounts
from new_accounts_daily
)

select
dr.activity_date as date,
dr.activity_date,
dau.active_accounts as dau,
mau.active_accounts as mau,
new_accounts_daily.new_accounts as new_accounts_daily,
new_accounts_monthly.new_accounts as new_accounts_monthly
from date_range as dr
left join active_accounts_daily as dau
on dr.activity_date = dau.activity_date
on dr.activity_date = dau.activity_date
left join active_accounts_monthly as mau
on dr.activity_date = mau.activity_date
left join new_accounts_daily
on dr.activity_date = new_accounts_daily.activity_date
left join new_accounts_monthly
on dr.activity_date = new_accounts_monthly.activity_date
order by date desc
order by activity_date desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
models:
- name: fct_perp_account_activity_arbitrum_sepolia
columns:
- name: date
- name: activity_date
description: "Activity date"
data_type: date
tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,35 @@ with active_accounts as (
),

date_range as (
select generate_series(
date(min(activity_date)),
date(max(activity_date)),
interval '1 day'
)::date as activity_date
from active_accounts
select
generate_series(
date(min(activity_date)),
date(max(activity_date)),
interval '1 day'
)::date as activity_date
from active_accounts
),

active_accounts_daily as (
select
date_range.activity_date,
count(distinct account_id) as active_accounts
from date_range
left join active_accounts using(activity_date)
group by date_range.activity_date
select
date_range.activity_date,
count(distinct active_accounts.account_id) as active_accounts
from date_range
left join active_accounts
on date_range.activity_date = active_accounts.activity_date
group by date_range.activity_date
),

active_accounts_monthly as (
select
select
date_range.activity_date,
count(distinct active_accounts.account_id) as active_accounts
from date_range
left join active_accounts
on active_accounts.activity_date >= date_range.activity_date - interval '27 days'
and active_accounts.activity_date <= date_range.activity_date
left join active_accounts
on
date_range.activity_date - interval '27 days'
<= active_accounts.activity_date
and date_range.activity_date >= active_accounts.activity_date
group by date_range.activity_date
),

Expand All @@ -45,40 +49,41 @@ new_accounts as (
account_id
from active_accounts
group by account_id
),
),

new_accounts_daily as (
select
activity_date,
count(account_id) as new_accounts
date_range.activity_date,
count(new_accounts.account_id) as new_accounts
from date_range
left join new_accounts on activity_date = start_date
group by activity_date, start_date
left join new_accounts
on date_range.activity_date = new_accounts.start_date
group by date_range.activity_date, new_accounts.start_date
),

new_accounts_monthly as (
select distinct
activity_date,
sum(new_accounts) over (
order by activity_date
range between interval '27 days' preceding and current row
) as new_accounts
from new_accounts_daily
activity_date,
sum(new_accounts) over (
order by activity_date
range between interval '27 days' preceding and current row
) as new_accounts
from new_accounts_daily
)

select
dr.activity_date as date,
dr.activity_date,
dau.active_accounts as dau,
mau.active_accounts as mau,
new_accounts_daily.new_accounts as new_accounts_daily,
new_accounts_monthly.new_accounts as new_accounts_monthly
from date_range as dr
left join active_accounts_daily as dau
on dr.activity_date = dau.activity_date
on dr.activity_date = dau.activity_date
left join active_accounts_monthly as mau
on dr.activity_date = mau.activity_date
left join new_accounts_daily
on dr.activity_date = new_accounts_daily.activity_date
left join new_accounts_monthly
on dr.activity_date = new_accounts_monthly.activity_date
order by date desc
order by activity_date desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
models:
- name: fct_perp_account_activity_base_mainnet
columns:
- name: date
- name: activity_date
description: "Activity date"
data_type: date
tests:
Expand Down
Loading

0 comments on commit ad9366e

Please sign in to comment.