Skip to content

Commit

Permalink
Create final models
Browse files Browse the repository at this point in the history
  • Loading branch information
lukej-rd committed Sep 19, 2024
1 parent e2ad4ec commit 07d873b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jaffle_shop/models/final/sales/_exposures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

exposures:
- name: fnl_sales_newcustomersmonthly
label: fnl_sales_newcustomersmonthly
description: Inksacio data app with dashboard showing the total number of new customers per month
type: dashboard
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: [email protected]
depends_on:
- ref('fnl_sales_newcustomersmonthly')
16 changes: 16 additions & 0 deletions jaffle_shop/models/final/sales/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

models:
- name: fnl_finance_newcustomersmonthly
access: public
config:
group: industry_operations
meta:
owner: [email protected]
description: |
This model contains one row per month and the total number of customers making their first order in that month.
columns:
- name: first_order_month
tests:
- unique
- not_null
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
DATE_TRUNC('month', first_order) AS first_order_month
-- No need to use count distinct here, as wh_customers has one row per customer
, COUNT(customer_id) AS new_customers

FROM {{ ref('wh_customers') }} AS customers

GROUP BY DATE_TRUNC('month', first_order)
12 changes: 12 additions & 0 deletions jaffle_shop/models/finance/_exposures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

exposures:
- name: fnl_finance_customerreturns
label: fnl_finance_customerreturns
description: Inksacio data app with dashboard showing the financial value of customer returns
type: dashboard
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: [email protected]
depends_on:
- ref('fnl_finance_customerreturns')
16 changes: 16 additions & 0 deletions jaffle_shop/models/finance/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

models:
- name: fnl_finance_customerreturns
access: public
config:
group: industry_operations
meta:
owner: [email protected]
description: |
This model contains one row per customer and the total financial value of their returned orders.
columns:
- name: customer_id
tests:
- unique
- not_null
9 changes: 9 additions & 0 deletions jaffle_shop/models/finance/fnl_finance_customerreturns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SELECT
customer_id
, SUM(amount) AS total_amount_returned

FROM {{ ref('wh_orders') }}

WHERE status = 'returned'

GROUP BY customer_id

0 comments on commit 07d873b

Please sign in to comment.