Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
fix Sinter failures (singer-io#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimercurio authored Nov 29, 2018
1 parent ea5920c commit ee2fab3
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 98 deletions.
3 changes: 1 addition & 2 deletions models/careplatform/base/careplatform_pages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{{ config(materialized='table') }}

select * from careplatform.pages
where
{% if target.name == 'dev' %}
timestamp > current_timestamp - interval '1 months'
where timestamp > current_timestamp - interval '1 months'
{% endif %}
8 changes: 0 additions & 8 deletions models/funnelio/base/funnelio_google_search_console.sql

This file was deleted.

6 changes: 0 additions & 6 deletions models/funnelio/transform/funnelio_performance_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ with choozle as (
select * from {{ ref( 'funnelio_google' ) }}
)

, google_search_console as (
select * from {{ ref( 'funnelio_google_search_console' ) }}
)

, linkedin as (
select * from {{ ref( 'funnelio_linkedin' ) }}
)
Expand All @@ -37,8 +33,6 @@ with choozle as (
union all
select * from google
union all
select * from google_search_console
union all
select * from linkedin
union all
select * from linkedin_organic
Expand Down
28 changes: 14 additions & 14 deletions models/meta/medops/medops_count_daus_by_org_monthly.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
with chats_all_time as (
select * from {{ ref( 'chats_all_time' ) }}
)
with
chats_all_time as (
select * from {{ ref('chats_all_time') }}
)

, users as (
select * from {{ ref( 'user_contract' ) }}
, user_contract as (
select * from {{ ref('user_contract') }}
)

select users.organization_name
, date_trunc('month', chats_all_time.created_at_day) as date_month
, count(chats_all_time.user_id) as count_dau
select user_contract.organization_id
, user_contract.organization_name
, date_trunc('month', chats_all_time.created_at_day) as date_month
, count(chats_all_time.user_id) as count_dau
from chats_all_time
inner join users
on chats_all_time.user_id = users.user_id
and chats_all_time.created_at_day <@
tsrange(timezone('America/Montreal', lower(users.during)),
timezone('America/Montreal', upper(users.during)))
group by 1,2
inner join user_contract
on chats_all_time.user_id = user_contract.user_id
and chats_all_time.created_at_day <@ user_contract.during_est
group by 1,2,3
26 changes: 15 additions & 11 deletions models/meta/medops/medops_count_maus_by_org.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
with chats_all_time as (
select * from {{ ref( 'chats_all_time' ) }}
)
with
chats_all_time as (
select * from {{ ref('chats_all_time') }}
)

, users as (
select * from {{ ref( 'user_contract' ) }}
, user_contract as (
select * from {{ ref('scribe_user_contract_detailed') }}
)

select users.organization_name
, date_trunc('month', chats_all_time.created_at_day) as date_month
, count(distinct users.user_id) as count_mau
select user_contract.organization_id
, user_contract.organization_name
, date_trunc('month', chats_all_time.created_at_day) as date_month
, count(distinct user_contract.user_id) as count_mau
from chats_all_time
inner join users using (user_id)
inner join user_contract
on chats_all_time.user_id = user_contract.user_id
and chats_all_time.created_at_day <@ user_contract.during_est
-- Before this date not all users had organizations
where created_at_day > '2017-10-01'
group by 1,2
where chats_all_time.created_at_day > '2017-10-01'
group by 1,2,3
55 changes: 32 additions & 23 deletions models/meta/medops/medops_usage_by_org_monthly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,38 @@
--

with maus as (
select * from {{ ref( 'medops_count_maus_by_org' ) }}
)
select * from {{ ref('medops_count_maus_by_org') }}
)

, daus as (
select * from {{ ref( 'medops_count_daus_by_org_monthly' ) }}
)
, daus as (
select * from {{ ref('medops_count_daus_by_org_monthly') }}
)

, paid_employees_monthly as (
select * from {{ ref( 'users_paid_employees_monthly' ) }}
)
, paid_employees_monthly as (
select * from {{ ref('users_paid_employees_monthly') }}
)

select paid_employees_monthly.date_month
, paid_employees_monthly.organization_name
, paid_employees_monthly.account_name
, paid_employees_monthly.count_paid_employees
, maus.count_mau
, daus.count_dau
, coalesce(maus.count_mau, 0)/paid_employees_monthly.count_paid_employees::float as mau_rate
, coalesce(daus.count_dau, 0)/paid_employees_monthly.count_paid_employees::float as dau_rate
from paid_employees_monthly
left join maus
on paid_employees_monthly.date_month = maus.date_month
and paid_employees_monthly.organization_name = maus.organization_name
left join daus
on paid_employees_monthly.date_month = daus.date_month
and paid_employees_monthly.organization_name = daus.organization_name
select paid_employees_monthly.date_month
, paid_employees_monthly.organization_id
, paid_employees_monthly.organization_name
, paid_employees_monthly.account_name
, paid_employees_monthly.count_paid_employees
, maus.count_mau
, daus.count_dau
, case
when paid_employees_monthly.count_paid_employees <> 0
then coalesce(maus.count_mau, 0)
/ paid_employees_monthly.count_paid_employees::float
else 0
end as mau_rate
, case
when paid_employees_monthly.count_paid_employees <> 0
then coalesce(daus.count_dau, 0)
/ paid_employees_monthly.count_paid_employees::float
else 0
end as dau_rate
from paid_employees_monthly
left join maus
using (date_month, organization_id)
left join daus
using (date_month, organization_id)
35 changes: 18 additions & 17 deletions models/meta/medops/medops_video_rate_by_org_monthly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,29 @@
--

with videos as (
select * from {{ ref( 'medops_videos_by_org_monthly' ) }}
select * from {{ ref('medops_videos_by_org_monthly') }}
)

, ubi_consults as (
select * from {{ ref( 'medops_ubisoft_clinic_consultation_count' ) }}
select * from {{ ref('medops_ubisoft_clinic_consultation_count') }}
)

, paid_employees_monthly as (
select * from {{ ref( 'users_paid_employees_monthly' ) }}
select * from {{ ref('users_paid_employees_monthly') }}
)

select paid_employees_monthly.date_month
, paid_employees_monthly.organization_name
, paid_employees_monthly.account_name
, coalesce(paid_employees_monthly.count_paid_employees, 0) as count_paid_employees
, coalesce(videos.count_videos, 0) as count_videos
, coalesce(ubi_consults.nurse_consultations, 0) as nurse_consultations
, coalesce(ubi_consults.gp_consultations, 0) as gp_consultations
, coalesce(ubi_consults.mental_health_consultations, 0) as mental_health_consultations
, coalesce(videos.count_videos, 0) /count_paid_employees::float as video_rate
from paid_employees_monthly
left join videos using (date_month, organization_name)
left join ubi_consults
on paid_employees_monthly.date_month = ubi_consults.date_month
and paid_employees_monthly.organization_name = 'Ubisoft Divertissements Inc. (Bureau de Montreal)'
select paid_employees_monthly.date_month
, paid_employees_monthly.organization_name
, paid_employees_monthly.account_name
, coalesce(paid_employees_monthly.count_paid_employees, 0) as count_paid_employees
, coalesce(videos.count_videos, 0) as count_videos
, coalesce(ubi_consults.nurse_consultations, 0) as nurse_consultations
, coalesce(ubi_consults.gp_consultations, 0) as gp_consultations
, coalesce(ubi_consults.mental_health_consultations, 0) as mental_health_consultations
, coalesce(videos.count_videos, 0) /count_paid_employees::float as video_rate
from paid_employees_monthly
left join videos using (date_month, organization_name)
left join ubi_consults
on paid_employees_monthly.date_month = ubi_consults.date_month
and paid_employees_monthly.organization_name
= 'Ubisoft Divertissements Inc. (Bureau de Montreal)'
32 changes: 16 additions & 16 deletions models/meta/medops/medops_videos_by_org_monthly.sql
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
with videos as (
select * from {{ ref( 'videos_by_ep_daily' ) }}
)
with
videos as (
select * from {{ ref('videos_by_ep_daily') }}
)

, users as (
select * from {{ ref( 'user_contract' ) }}
)
, user_contract as (
select * from {{ ref('user_contract') }}
)

select patients.organization_name
, date_trunc('month', videos.date_day_est) as date_month
, count(distinct
concat(patients.user_id,
select user_contract.organization_id
, user_contract.organization_name
, date_trunc('month', videos.date_day_est) as date_month
, count(distinct
concat(user_contract.user_id,
date_trunc('day',
videos.date_day_est)
)
) as count_videos
from videos
inner join users as patients
on videos.patient_id = patients.user_id
and tsrange(timezone('America/Montreal', lower(patients.during)),
timezone('America/Montreal', upper(patients.during)))
@> videos.date_day_est
inner join user_contract
on videos.patient_id = user_contract.user_id
and videos.date_day_est <@ user_contract.during_est
where videos.includes_video_gp
group by 1,2
group by 1,2,3
2 changes: 1 addition & 1 deletion models/scribe/transform/scribe_organizations_daily.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ select date_trunc('month', organizations_day.date_day) as date_month
, count(distinct contracts.participant_id) as active_contracts
from organizations_day
left join contracts
on organizations_day.date_day_range && contracts.during
on organizations_day.date_day_range && contracts.during
and organizations_day.organization_id = contracts.organization_id
group by 1,2,3,4,5,6,7,8,9

0 comments on commit ee2fab3

Please sign in to comment.