diff --git a/jaffle_shop/models/final/sales/_exposures.yml b/jaffle_shop/models/final/sales/_exposures.yml new file mode 100644 index 000000000..6d08c3630 --- /dev/null +++ b/jaffle_shop/models/final/sales/_exposures.yml @@ -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: luke.ralphs-davies@octoenergy.com + depends_on: + - ref('fnl_sales_newcustomersmonthly') \ No newline at end of file diff --git a/jaffle_shop/models/final/sales/_models.yml b/jaffle_shop/models/final/sales/_models.yml new file mode 100644 index 000000000..63f2231e7 --- /dev/null +++ b/jaffle_shop/models/final/sales/_models.yml @@ -0,0 +1,16 @@ +version: 2 + +models: + - name: fnl_finance_newcustomersmonthly + access: public + config: + group: industry_operations + meta: + owner: luke.ralphs-davies@octoenergy.com + 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 diff --git a/jaffle_shop/models/final/sales/fnl_sales_newcustomersmonthly.sql b/jaffle_shop/models/final/sales/fnl_sales_newcustomersmonthly.sql new file mode 100644 index 000000000..9e6880b09 --- /dev/null +++ b/jaffle_shop/models/final/sales/fnl_sales_newcustomersmonthly.sql @@ -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) \ No newline at end of file diff --git a/jaffle_shop/models/finance/_exposures.yml b/jaffle_shop/models/finance/_exposures.yml new file mode 100644 index 000000000..c26f76f58 --- /dev/null +++ b/jaffle_shop/models/finance/_exposures.yml @@ -0,0 +1,21 @@ +version: 2 + +exposures: + - name: fnl_finance_customerreturns + label: fnl_finance_customerreturns + description: Inksacio data app with dashboard for dbt certification + type: dashboard + url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/ + owner: + email: example.email@octoenergy.com + depends_on: + - ref('fnl_finance_returns_by_customer') + - name: fnl_sales_newcustomers + label: fnl_sales_newcustomers + description: Inksacio data app with dashboard for dbt certification + type: dashboard + url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/ + owner: + email: example.email@octoenergy.com + depends_on: + - ref('fnl_sales_newcustomers') \ No newline at end of file diff --git a/jaffle_shop/models/finance/_models.yml b/jaffle_shop/models/finance/_models.yml new file mode 100644 index 000000000..7c82eb7c2 --- /dev/null +++ b/jaffle_shop/models/finance/_models.yml @@ -0,0 +1,16 @@ +version: 2 + +models: + - name: fnl_finance_customerreturns + access: public + config: + group: industry_operations + meta: + owner: luke.ralphs-davies@octoenergy.com + 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 diff --git a/jaffle_shop/models/finance/fnl_finance_customerreturns.sql b/jaffle_shop/models/finance/fnl_finance_customerreturns.sql new file mode 100644 index 000000000..cd084e1b0 --- /dev/null +++ b/jaffle_shop/models/finance/fnl_finance_customerreturns.sql @@ -0,0 +1,9 @@ +SELECT + customer_id + , SUM(amount) AS total_amount_returned + +FROM {{ ref('wh_orders') }} + +WHERE status = 'returned' + +GROUP BY customer_id