Initial open-source release

This commit is contained in:
Andrey Avtomonov 2026-05-10 23:12:26 +02:00
commit 1a42152e6f
1199 changed files with 257054 additions and 0 deletions

View file

@ -0,0 +1,35 @@
name: churn_risk
description: |
Customer churn risk score combining tenure,
usage trends, and support burden.
sql: |
SELECT
c.id AS customer_id,
c.name AS customer_name,
calculate_churn_score(c.id) AS score,
CASE
WHEN c.arr < 50000 THEN 'SMB'
WHEN c.arr < 500000 THEN 'Mid-Market'
ELSE 'Enterprise'
END AS customer_type
FROM customers c
JOIN usage_summary u ON c.id = u.customer_id
JOIN ticket_summary t ON c.id = t.customer_id
grain: [customer_id]
columns:
- name: customer_id
type: number
- name: customer_name
type: string
- name: score
type: number
- name: customer_type
type: string
joins:
- to: customers
"on": customer_id = customers.id
relationship: many_to_one
measures:
- name: avg_risk
expr: avg(score)
description: "Average churn risk score"

View file

@ -0,0 +1,19 @@
name: customers
table: public.customers
grain: [id]
columns:
- name: id
type: number
- name: name
type: string
- name: segment
type: string
- name: region_id
type: number
- name: created_at
type: time
role: time
joins:
- to: regions
"on": region_id = regions.id
relationship: many_to_one

View file

@ -0,0 +1,21 @@
name: order_items
table: public.order_items
grain: [id]
columns:
- name: id
type: number
- name: order_id
type: number
- name: product_id
type: number
- name: quantity
type: number
- name: price
type: number
joins:
- to: orders
"on": order_id = orders.id
relationship: many_to_one
- to: products
"on": product_id = products.id
relationship: many_to_one

View file

@ -0,0 +1,39 @@
name: orders
table: public.orders
grain: [id]
columns:
- name: id
type: number
- name: customer_id
type: number
- name: amount
type: number
- name: cost
type: number
- name: status
type: string
- name: created_at
type: time
role: time
joins:
- to: customers
"on": customer_id = customers.id
relationship: many_to_one
measures:
- name: revenue
expr: sum(amount)
filter: "status != 'refunded'"
description: "Net revenue excluding refunds"
- name: order_count
expr: count(id)
- name: total_amount
expr: sum(amount)
description: "Total order amount across all statuses"
- name: paid_amount
expr: sum(amount)
filter: "status = 'paid'"
description: "Total amount from paid orders only"
- name: refunded_amount
expr: sum(amount)
filter: "status = 'refunded'"
description: "Total amount from refunded orders"

View file

@ -0,0 +1,12 @@
name: products
table: public.products
grain: [id]
columns:
- name: id
type: number
- name: name
type: string
- name: category
type: string
- name: price
type: number

View file

@ -0,0 +1,8 @@
name: regions
table: public.regions
grain: [id]
columns:
- name: id
type: number
- name: name
type: string