Skip to main content

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​

  1. The user opens the dashboard and cms-web calls GET /api/dashboard/total-friends with query parameters described by QueryDashboardStatsDto.
  2. The _getLineUserStats service builds a query against the line_user table with these base conditions:
    • line_oa_id must match the lineOaId read from CLS
    • created_date must not exceed the supplied date, allowing historical figures
    • user_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 NULL automatically because the entity declares gorm.DeletedAt — the same thing the legacy TypeORM QueryBuilder did
  3. Per-metric conditions are then layered on top of that base query, for example to count follows, unfollows and blocks separately.
  4. 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").

MethodRouteHandlerPolicy
GET/api/dashboard/total-friendssvc.getTotalFriendsHandlerread 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 a lineOaId in the token. PolicyModuleDashboard is metadata only and is not yet enforced.
  • Tables — line_user and line_oa.
  • CLS — lineOaId from 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).