Skip to content

feat: add user activity statistics collection and query APIs - #664

Merged
Seechi-Yolo merged 1 commit into
mainfrom
dms/feat-user-activity
Aug 13, 2026
Merged

feat: add user activity statistics collection and query APIs#664
Seechi-Yolo merged 1 commit into
mainfrom
dms/feat-user-activity

Conversation

@LordofAvernus

@LordofAvernus LordofAvernus commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

将用户活跃度统计功能的社区版部分从 dms-ee 的定制分支上行到主干。本 PR 只含 CE 代码:请求路径到业务模块的归类、查询接口契约与 controller、保留期系统变量、cron 任务接线,以及 _ce.go 空桩。真正的采集与聚合实现由企业版提供(见 actiontech/dms-ee#960)。

主要内容:

  • api/dms/service/v1/user_activity.go:概览、日趋势、模块分布、时段分布、用户排行五个查询接口的请求 / 响应模型与 swagger 注解。
  • internal/apiserver/middleware/user_activity_path.go:把 HTTP 请求路径归一化并映射到业务模块,供采集侧标注来源;配套单测覆盖动态路径段与非业务路径。
  • internal/apiserver/service/dms_controller_user_activity.go + router.go:controller 与路由注册。
  • internal/dms/biz/user_activity.gocron_task.go:领域模型、活跃时长计算与 cron 任务定义。
  • internal/dms/biz/system_variable.gostorage/system_variable.gopkg/dms-common/api/dms/v1/system_variable.go:新增访问日志保留时长系统变量。
  • *_ce.go:社区版空桩,采集不落库,查询接口返回功能不可用。

Problem

用户活跃度报表此前只存在于 CSVW 定制分支(dms-eecsvw-4.2505.x),未进入主干,后续版本无法继承。本 PR 与 actiontech/dms-ee#960 一起把该能力上行,按 CE/EE 规范拆分:通用契约与桩进 CE,采集与聚合实现留在 EE。

Test plan

  • make EDITION=ce docker_install 构建通过
  • go test ./internal/dms/biz/ ./internal/apiserver/middleware/:活跃时长计算、请求路径归一化与业务模块判定用例全部通过
  • go vet ./internal/... ./api/... ./pkg/dms-common/api/...:无本次改动引入的新问题
  • 完整链路已在 dms-ee dev 分支(CE+EE 合并态)本地部署验证:真实调用产生访问记录,五个查询接口返回与流量一致的统计结果

internal/dms/bizTestUpdateUserBusinessWritePermission 的失败在 main 基线上已存在,与本次改动无关。

配套前端:actiontech/dms-ui#878

Introduce the user activity report skeleton: request path classification into
business modules, the query API contract and controller, the retention system
variable, and the cron task wiring. The collection and aggregation behaviour
itself is provided by the enterprise build; the community build keeps no-op
stubs so the endpoints report the feature as unavailable.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@Seechi-Yolo
Seechi-Yolo merged commit dd90326 into main Aug 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants