Summary Dashboard
Overview
The dashboard is the first screen a user sees after selecting a LINE OA, presenting that OA's key figures.
On the API side this module is very small — a single endpoint returning friend count statistics. The other figures shown on the cms-web dashboard come from endpoints belonging to other modules, such as campaign tracking and the friend track report, rather than being consolidated here.
Business Flow
- The user opens the dashboard and cms-web calls
GET /api/dashboard/total-friendswith query parameters described byQueryDashboardStatsDto. - The
_getLineUserStatsservice builds a query against theline_usertable with these base conditions:line_oa_idmust match thelineOaIdread from CLScreated_datemust not exceed the supplied date, allowing historical figuresuser_id IS NOT NULL, so only rows actually linked to a LINE user are counted- soft deletion is handled by GORM, which appends
deleted_date IS NULLautomatically because the entity declaresgorm.DeletedAt— the same thing the legacy TypeORM QueryBuilder did
- Per-metric conditions are then layered on top of that base query, for example to count follows, unfollows and blocks separately.
- The complete set of figures is returned to cms-web, which renders the stat cards and charts.
Key Files & Functions
The code lives in internal/modules/dashboard/, split across controller.go, service.go
and dto.go.
The route is registered on authed.Group("/dashboard").
| Method | Route | Handler | Policy |
|---|---|---|---|
| GET | /api/dashboard/total-friends | svc.getTotalFriendsHandler | read dashboard |
The key internal function is _getLineUserStats, a direct port of the legacy
DashboardService._getLineUserStats.
This module has neither ModuleGate nor SuperAdminGuard — callers only need to pass the
global JwtAuth.
Connections to Other Services
- Permissions — requires the global
JwtAuth, which mandates alineOaIdin the token.PolicyModuleDashboardis metadata only and is not yet enforced. - Tables —
line_userandline_oa. - CLS —
lineOaIdfrom the request context scopes the query. - Related modules — LINE User Management, All Friend Listing (the detailed report), Campaign Management (campaign statistics) and Friend Track (friend source statistics).