-
Notifications
You must be signed in to change notification settings - Fork 7
add refund rate metric [sample PR for demo] #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: tyoma/mock-de-journey
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||||
| dbt: | ||||||||
| project: shopify_analytics | ||||||||
| path: /Users/Artem.Trofimov/Work/databao-cli/mock-cli/test-shopify | ||||||||
| databao: | ||||||||
| path: /Users/Artem.Trofimov/Work/databao-cli/mock-cli/test-shopify/.databao | ||||||||
| connection: | ||||||||
| type: duckdb | ||||||||
| path: shopify.duckdb | ||||||||
| schema: main | ||||||||
| threads: 4 | ||||||||
| user: | ||||||||
| email: artem@databao.app | ||||||||
| token: mock_oauth_token_a1b2c3d4 | ||||||||
|
Comment on lines
+11
to
+13
|
||||||||
| user: | |
| email: artem@databao.app | |
| token: mock_oauth_token_a1b2c3d4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| question,gold_sql,mf_query,metric,formula | ||
| What is the refund rate by month?,,"mf query --metrics refund_rate --group-by metric_time__month",refund_rate,COUNT(*) WHERE financial_status='refunded' / COUNT(*) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1 @@ | ||||||
| id: 7e32390b-2360-4c50-993c-408e4855247f | ||||||
|
||||||
| id: 7e32390b-2360-4c50-993c-408e4855247f | |
| # Local per-user identifier intentionally omitted from source control. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| metrics: | ||
| - name: order_count | ||
| description: "Total number of orders" | ||
| type: simple | ||
| type_params: | ||
| measure: order_count | ||
| label: "Order Count" | ||
|
|
||
| - name: refunded_order_count | ||
| description: "Number of orders that were refunded" | ||
| type: simple | ||
| type_params: | ||
| measure: refunded_order_count | ||
| filter: "{{ Dimension('order__financial_status') }} = 'refunded'" | ||
| label: "Refunded Orders" | ||
|
|
||
| - name: refund_rate | ||
| description: "Share of orders that were refunded" | ||
| type: ratio | ||
| type_params: | ||
| numerator: refunded_order_count | ||
| denominator: order_count | ||
| label: "Refund Rate" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||
| semantic_models: | ||||||
| - name: orders | ||||||
| description: "Shopify orders with payment and fulfillment status" | ||||||
| model: ref('stg_orders') | ||||||
| defaults: | ||||||
| agg_time_dimension: created_at | ||||||
| entities: | ||||||
| - name: order | ||||||
| type: primary | ||||||
| expr: id | ||||||
| - name: customer | ||||||
| type: foreign | ||||||
| expr: customer_id | ||||||
| dimensions: | ||||||
| - name: created_at | ||||||
| type: time | ||||||
| type_params: | ||||||
| time_granularity: day | ||||||
| - name: financial_status | ||||||
| type: categorical | ||||||
| - name: fulfillment_status | ||||||
| type: categorical | ||||||
| measures: | ||||||
| - name: order_count | ||||||
| description: "Total number of orders" | ||||||
| agg: count | ||||||
| expr: id | ||||||
| - name: refunded_order_count | ||||||
| description: "Number of orders with financial_status = 'refunded'" | ||||||
|
||||||
| description: "Number of orders with financial_status = 'refunded'" | |
| description: "Unfiltered count of orders; refunded-only semantics must be applied downstream via a metric-level filter on financial_status = 'refunded'" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| {{ config(materialized='table') }} | ||
|
|
||
| select | ||
| cast(range as date) as date_day | ||
| from generate_series( | ||
| cast('2020-01-01' as date), | ||
| cast('2030-01-01' as date), | ||
| interval '1 day' | ||
| ) as t(range) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| select * from {{ source('shopify_analytics', 'orders') }} |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| select | ||||||||||||||||||||
| cast(range as date) as date_day | ||||||||||||||||||||
| from generate_series( | ||||||||||||||||||||
| cast('2020-01-01' as date), | ||||||||||||||||||||
| cast('2030-01-01' as date), | ||||||||||||||||||||
| interval '1 day' | ||||||||||||||||||||
| ) as t(range) | ||||||||||||||||||||
|
Comment on lines
+1
to
+9
|
||||||||||||||||||||
| select | |
| cast(range as date) as date_day | |
| from generate_series( | |
| cast('2020-01-01' as date), | |
| cast('2030-01-01' as date), | |
| interval '1 day' | |
| ) as t(range) |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1 @@ | ||||
| select * from "shopify"."main"."orders" | ||||
|
||||
| select * from "shopify"."main"."orders" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| create table | ||||||||||||||||||||||||||||||||||||||||||||||||
| "shopify"."main"."metricflow_time_spine__dbt_tmp" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| as ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| select | ||||||||||||||||||||||||||||||||||||||||||||||||
| cast(range as date) as date_day | ||||||||||||||||||||||||||||||||||||||||||||||||
| from generate_series( | ||||||||||||||||||||||||||||||||||||||||||||||||
| cast('2020-01-01' as date), | ||||||||||||||||||||||||||||||||||||||||||||||||
| cast('2030-01-01' as date), | ||||||||||||||||||||||||||||||||||||||||||||||||
| interval '1 day' | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) as t(range) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+21
|
||||||||||||||||||||||||||||||||||||||||||||||||
| create table | |
| "shopify"."main"."metricflow_time_spine__dbt_tmp" | |
| as ( | |
| select | |
| cast(range as date) as date_day | |
| from generate_series( | |
| cast('2020-01-01' as date), | |
| cast('2030-01-01' as date), | |
| interval '1 day' | |
| ) as t(range) | |
| ); | |
| -- Generated dbt build artifact removed from version-controlled source. | |
| -- This file under target/run should be regenerated by dbt and not committed. |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| create view "shopify"."main"."stg_orders__dbt_tmp" as ( | ||||||||||||
| select * from "shopify"."main"."orders" | ||||||||||||
| ); | ||||||||||||
|
Comment on lines
+1
to
+5
|
||||||||||||
| create view "shopify"."main"."stg_orders__dbt_tmp" as ( | |
| select * from "shopify"."main"."orders" | |
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file appears to contain local, machine-specific absolute paths (e.g., under /Users/...) which will break for other environments and can leak developer workstation details. Consider storing paths relative to the dbt project root, or using env vars/placeholders, and avoid committing the generated per-user config to the repo.