Replace hardcoded Keboola-specific metrics card in Data Catalog with dynamic Jinja template that renders whatever metric YAMLs exist in docs/metrics/. Add 10 sample e-commerce metric definitions across 4 categories (revenue, customers, marketing, support) that align with the sample data generator tables. Key changes: - MetricParser: new category colors + dynamic sql_* field discovery - _load_metrics_data(): scans docs/metrics/*/*.yml with prod fallback - catalog.html: 240 lines hardcoded HTML -> 35 lines Jinja loop - metric_modal.js: regex-based category class removal, new categories - 21 tests validating YAML schema, parser, and loader
47 lines
1.5 KiB
YAML
47 lines
1.5 KiB
YAML
- name: avg_resolution_hours
|
|
display_name: Average Resolution Time
|
|
category: support
|
|
type: average
|
|
unit: hours
|
|
grain: monthly
|
|
time_column: created_at
|
|
table: support_tickets
|
|
expression: "AVG(EXTRACT(EPOCH FROM (resolved_at - created_at)) / 3600)"
|
|
description: "Average time in hours from ticket creation to resolution. Key support team performance metric. Lower values indicate more efficient support operations."
|
|
dimensions:
|
|
- priority
|
|
- category
|
|
- agent
|
|
- channel
|
|
notes:
|
|
- "Only includes resolved tickets (excludes open and escalated)"
|
|
- "Business hours calculation is not applied; uses wall-clock time"
|
|
- "Outliers above 720 hours (30 days) are excluded from average"
|
|
synonyms:
|
|
- resolution_time
|
|
- time_to_resolve
|
|
- ttr
|
|
sql: |
|
|
SELECT
|
|
DATE_TRUNC('month', created_at) AS month,
|
|
ROUND(
|
|
AVG(EXTRACT(EPOCH FROM (resolved_at - created_at)) / 3600), 1
|
|
) AS avg_resolution_hours,
|
|
COUNT(*) AS resolved_tickets
|
|
FROM support_tickets
|
|
WHERE resolved_at IS NOT NULL
|
|
AND EXTRACT(EPOCH FROM (resolved_at - created_at)) / 3600 <= 720
|
|
GROUP BY 1
|
|
ORDER BY 1
|
|
sql_by_priority: |
|
|
SELECT
|
|
priority,
|
|
ROUND(
|
|
AVG(EXTRACT(EPOCH FROM (resolved_at - created_at)) / 3600), 1
|
|
) AS avg_resolution_hours,
|
|
COUNT(*) AS ticket_count
|
|
FROM support_tickets
|
|
WHERE resolved_at IS NOT NULL
|
|
AND EXTRACT(EPOCH FROM (resolved_at - created_at)) / 3600 <= 720
|
|
GROUP BY 1
|
|
ORDER BY 2
|