> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Dashboard — 计算配置

> **Source of truth**: `studio-website-monorepo/apps/api/src/routes/v3/dashboard-summary.ts` · `dashboard-staff.ts`
> **last\_verified**: 2026-06-15

Dashboard 指标来自多个 endpoint，全部按 `store_id` 隔离。

***

## Performance Tab

### KPI 卡片

数据来自 `GET /v3/dashboard/summary?storeId=...&period=week|month`。

| 指标            | 产品定义                       | SQL 口径                                                                                                  | 状态    |
| ------------- | -------------------------- | ------------------------------------------------------------------------------------------------------- | ----- |
| Call Volume   | 选定时段内的通话总数                 | `COUNT(*)` from `calls` WHERE `store_id` + time range                                                   | ✅ 已接线 |
| Outbound      | 外呼数                        | `COUNT(*) FILTER (WHERE direction = 'Outbound')`                                                        | ✅ 已接线 |
| Intros Booked | 成功的 revenue\_impacting 通话数 | `COUNT(*) FILTER (WHERE primary_outcome_result = 'success' AND primary_category = 'revenue_impacting')` | ✅ 已接线 |
| Cancel Saves  | 挽留成功数                      | `COUNT(*) FILTER (WHERE primary_outcome_result = 'retained')`                                           | ✅ 已接线 |
| Tasks Closed  | 选定时段内关闭的任务数                | `COUNT(*) FROM tasks WHERE status = 'closed' AND closed_at >= 当期起点`                                     | ✅ 已接线 |

> **Intros Booked 口径注意**：summary endpoint 用的是 `primary_outcome_result = 'success' AND primary_category = 'revenue_impacting'`，不是按 `intro_booking` subcategory 筛选。与 multi-store endpoint 的 `intro_booking` 口径不同。

趋势：当期 vs 上期同长度时段，delta = `(当期 - 上期) / 上期 × 100`。

### 快捷牵引

| 牵引             | 数据来源                                                                                                                       |
| -------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Lead Follow-up | `GET /v3/dashboard/overview` → `leadFunnel` 查询                                                                             |
| Task Queue     | `tasks` 表 `WHERE status = 'open' AND due_at < NOW()` 计数（逾期未完成任务，对应 multi-store endpoint 的 `tasks_overdue`；无独立的纯 open 计数端点） |
| Manager Review | `GET /v3/dashboard/coaching-highlights`                                                                                    |

***

## Team Tab

数据来自 `GET /v3/dashboard/staff?storeId=...&startDate=...&endDate=...`。

按 `staff_name` 分组聚合，只统计 `call_state IN ('human_conversation', 'voicemail')` 且 `staff_name IS NOT NULL` 的通话。

| 指标                   | SQL 口径                                                                                                                                                                             | 状态    |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| Calls                | `COUNT(*)` per staff                                                                                                                                                               | ✅ 已接线 |
| Inbound / Outbound   | `FILTER (WHERE direction = 'Inbound'/'Outbound')`                                                                                                                                  | ✅ 已接线 |
| Intro Calls          | `FILTER (WHERE primary_subcategory = 'intro_booking')`                                                                                                                             | ✅ 已接线 |
| Membership Sales     | `FILTER (WHERE primary_category = 'revenue_impacting' AND primary_subcategory IN ('membership_purchase_related', 'reactivation_purchase') AND primary_outcome_result = 'success')` | ✅ 已接线 |
| Cancellation Saves   | `FILTER (WHERE primary_subcategory = 'membership_cancel' AND primary_outcome_result = 'retained')`                                                                                 | ✅ 已接线 |
| Task Completion Rate | 从 `tasks` 表按 `closed_by_staff_name` 聚合 `closed / total`                                                                                                                            | ✅ 已接线 |
| Coaching Flag Rate   | `coaching_worthy / eligible_calls`（eligible = duration > 60s + 有 coaching 内容）                                                                                                      | ✅ 已接线 |
| WoW Direction        | 当期 vs 上期 total\_calls 对比 → up / down / flat                                                                                                                                        | ✅ 已接线 |

> **Live / Voicemail / No Answer**：prototype 的 Team tab 展示这三列。⚠️ 待开发 — 当前 staff endpoint 不返回这三类拆分，且 SQL 过滤了 `call_state IN ('human_conversation', 'voicemail')`，`no_answer` 不在结果集中。需后端扩展。
