From 60a462ed262da9b28131bec7d31884a0e83c2d94 Mon Sep 17 00:00:00 2001 From: Matthieu Di Mercurio Date: Thu, 29 Nov 2018 12:14:34 -0500 Subject: [PATCH] add segment recency tests (#84) --- models/careplatform/base/careplatform_tracks.sql | 3 +++ models/careplatform/base/schema.yml | 11 +++++++++++ models/countdown/base/countdown_tracks.sql | 3 +++ models/countdown/base/schema.yml | 14 ++++++++++++++ models/delighted/base/schema.yml | 6 ++++++ models/messaging/base/schema.yml | 15 +++++++++++++++ models/patientapp/base/schema.yml | 6 ++++++ models/scribe/base/schema.yml | 12 ++++++++++++ models/scribe/base/scribe_tracks.sql | 3 +++ models/usher/base/schema.yml | 16 ++++++++++++++++ models/usher/base/usher_tracks.sql | 3 +++ style_guide.md | 1 + 12 files changed, 93 insertions(+) create mode 100644 models/careplatform/base/careplatform_tracks.sql create mode 100644 models/countdown/base/countdown_tracks.sql create mode 100644 models/countdown/base/schema.yml create mode 100644 models/messaging/base/schema.yml create mode 100644 models/scribe/base/scribe_tracks.sql create mode 100644 models/usher/base/schema.yml create mode 100644 models/usher/base/usher_tracks.sql diff --git a/models/careplatform/base/careplatform_tracks.sql b/models/careplatform/base/careplatform_tracks.sql new file mode 100644 index 00000000..093ae600 --- /dev/null +++ b/models/careplatform/base/careplatform_tracks.sql @@ -0,0 +1,3 @@ +{{ config(materialized='view') }} + +select * from careplatform.tracks diff --git a/models/careplatform/base/schema.yml b/models/careplatform/base/schema.yml index 76477620..36ebe034 100644 --- a/models/careplatform/base/schema.yml +++ b/models/careplatform/base/schema.yml @@ -51,3 +51,14 @@ models: - name: timestamp tests: - not_null + + - name: careplatform_tracks + columns: + - name: timestamp + tests: + - not_null + tests: + - dbt_utils.recency: + field: timestamp + datepart: hour + interval: 15 diff --git a/models/countdown/base/countdown_tracks.sql b/models/countdown/base/countdown_tracks.sql new file mode 100644 index 00000000..b42c644f --- /dev/null +++ b/models/countdown/base/countdown_tracks.sql @@ -0,0 +1,3 @@ +{{ config(materialized='view') }} + +select * from countdown.tracks diff --git a/models/countdown/base/schema.yml b/models/countdown/base/schema.yml new file mode 100644 index 00000000..d811e678 --- /dev/null +++ b/models/countdown/base/schema.yml @@ -0,0 +1,14 @@ + +version: 2 + +models: + - name: countdown_tracks + columns: + - name: timestamp + tests: + - not_null + tests: + - dbt_utils.recency: + field: timestamp + datepart: hour + interval: 15 diff --git a/models/delighted/base/schema.yml b/models/delighted/base/schema.yml index e00d95b6..3cc12d4b 100644 --- a/models/delighted/base/schema.yml +++ b/models/delighted/base/schema.yml @@ -28,6 +28,12 @@ models: tests: - not_null + tests: + - dbt_utils.recency: + field: timestamp + datepart: hour + interval: 24 + - name: delighted_nps_dm_survey columns: - name: email diff --git a/models/messaging/base/schema.yml b/models/messaging/base/schema.yml new file mode 100644 index 00000000..a112bc03 --- /dev/null +++ b/models/messaging/base/schema.yml @@ -0,0 +1,15 @@ + +version: 2 + +models: + - name: messaging_posts + columns: + - name: created_at + tests: + - not_null + + tests: + - dbt_utils.recency: + field: created_at + datepart: hour + interval: 15 diff --git a/models/patientapp/base/schema.yml b/models/patientapp/base/schema.yml index 909941a4..752048ab 100644 --- a/models/patientapp/base/schema.yml +++ b/models/patientapp/base/schema.yml @@ -19,3 +19,9 @@ models: - not_null - accepted_values: values: ['iOS', 'Android', 'Desktop'] + + tests: + - dbt_utils.recency: + field: timestamp + datepart: hour + interval: 15 diff --git a/models/scribe/base/schema.yml b/models/scribe/base/schema.yml index bee2d9f4..8dff3b66 100644 --- a/models/scribe/base/schema.yml +++ b/models/scribe/base/schema.yml @@ -134,3 +134,15 @@ models: - name: timestamp tests: - not_null + + - name: scribe_tracks + columns: + - name: timestamp + tests: + - not_null + + tests: + - dbt_utils.recency: + field: timestamp + datepart: hour + interval: 15 diff --git a/models/scribe/base/scribe_tracks.sql b/models/scribe/base/scribe_tracks.sql new file mode 100644 index 00000000..54a5f0c9 --- /dev/null +++ b/models/scribe/base/scribe_tracks.sql @@ -0,0 +1,3 @@ +{{ config(materialized='view') }} + +select * from scribe.tracks diff --git a/models/usher/base/schema.yml b/models/usher/base/schema.yml new file mode 100644 index 00000000..c162c3ea --- /dev/null +++ b/models/usher/base/schema.yml @@ -0,0 +1,16 @@ + +version: 2 + +models: + + - name: usher_tracks + columns: + - name: timestamp + tests: + - not_null + + tests: + - dbt_utils.recency: + field: timestamp + datepart: hour + interval: 15 diff --git a/models/usher/base/usher_tracks.sql b/models/usher/base/usher_tracks.sql new file mode 100644 index 00000000..2d744204 --- /dev/null +++ b/models/usher/base/usher_tracks.sql @@ -0,0 +1,3 @@ +{{ config(materialized='view') }} + +select * from usher.tracks diff --git a/style_guide.md b/style_guide.md index 62f715c7..9f3b28bd 100644 --- a/style_guide.md +++ b/style_guide.md @@ -108,3 +108,4 @@ having count(*) > 1 * Every model should be tested in a schema.yml file * At minimum, unique and foreign key constraints should be tested (if applicable) * Any failing tests should be fixed or explained prior to requesting a review +* Every Segment schema should be tested for recency. The prefered way of testing is to check that the last timestamp was received less than 15 hours ago in the tracks table.