diff --git a/openspec/changes/add-lead-dashboard/design.md b/openspec/changes/add-lead-dashboard/design.md index 53053b7..76f1570 100644 --- a/openspec/changes/add-lead-dashboard/design.md +++ b/openspec/changes/add-lead-dashboard/design.md @@ -71,7 +71,7 @@ Rates are not sent; the portal divides. `GET /api/admin/dashboard/leads?from=2026-11-01&to=2026-11-30&companyId=2` under `@AdminModule("BO_DASHBOARD")`: - `from`/`to` optional; when absent, from = first day of the current Malaysian month, to = today (Malaysia). -- Bad date format or from after to → 400 `{code: "INVALID_PERIOD", message}`. +- Bad date format, from after to, or a range of more than 731 days (two years) → 400 `INVALID_PERIOD` (ProblemDetail: `code`, `detail`). The cap keeps one request from building an unbounded bucket list in services-counter, which also refuses a range over 731 days. - bucket = `DAY` when `to - from + 1 <= 62` days, else `MONTH`. - company from `AdminCompanyScope.scope(caller, companyId)`. - Response: the counter response plus `from`, `to`, `bucket`, and each salesperson row gains `name` (the user's name, or null for Unassigned and for a user that no longer exists). Salesperson names are resolved with the existing per-request map pattern. diff --git a/openspec/changes/add-lead-dashboard/specs/lead-dashboard/spec.md b/openspec/changes/add-lead-dashboard/specs/lead-dashboard/spec.md index 1c9ccbc..2a14c1f 100644 --- a/openspec/changes/add-lead-dashboard/specs/lead-dashboard/spec.md +++ b/openspec/changes/add-lead-dashboard/specs/lead-dashboard/spec.md @@ -17,7 +17,7 @@ The system SHALL show the lead dashboard on the back-office home page to users g ### Requirement: Dashboard period -The dashboard SHALL cover a period of whole days in Malaysia time (Asia/Kuala_Lumpur): this month up to today (the default), last month, or a custom range from one date to another, both included. A range whose start is after its end SHALL be refused with a message. The trend SHALL be counted by day for a period of up to 62 days and by month for a longer one, and SHALL list every day or month in the period, with zero where nothing happened. +The dashboard SHALL cover a period of whole days in Malaysia time (Asia/Kuala_Lumpur): this month up to today (the default), last month, or a custom range from one date to another, both included. A range whose start is after its end, or that spans more than 731 days, SHALL be refused with a message. The trend SHALL be counted by day for a period of up to 62 days and by month for a longer one, and SHALL list every day or month in the period, with zero where nothing happened. #### Scenario: Default period @@ -40,6 +40,11 @@ The dashboard SHALL cover a period of whole days in Malaysia time (Asia/Kuala_Lu - **WHEN** the user picks a start date after the end date - **THEN** the dashboard shows a message and no figures, and the endpoint responds 400 +#### Scenario: Range too long + +- **WHEN** the user picks 2024-01-01 to 2026-12-31 +- **THEN** the dashboard shows a message and no figures, and the endpoint responds 400 + ### Requirement: Capture figures For the chosen period the dashboard SHALL show the captures (event leads captured in the period, so a person captured at two events counts twice), the new leads (captures whose lead type is NEW), the conversion rate (the share of the period's captures whose current status is WON, shown as a dash when there are no captures), a funnel of the period's captures by current status (OPEN, CONTACTED, QUALIFIED, WON, LOST) and the captures in the trend.