Skip to content

Go: refactor system stats - #17089

Merged
JinHai-CN merged 3 commits into
infiniflow:mainfrom
JinHai-CN:fix563
Jul 20, 2026
Merged

JinHai-CN merged 3 commits into
infiniflow:mainfrom
JinHai-CN:fix563

Conversation

@JinHai-CN

Copy link
Copy Markdown
Member

Summary

Move stats to a specific service from system

@JinHai-CN JinHai-CN added the ci Continue Integration label Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The stats endpoint now uses dedicated StatsService and StatsHandler types, wired through router construction and server startup. Admin setup also invokes an empty enterprise-edition route registration hook.

Changes

Stats service separation

Layer / File(s) Summary
Dedicated stats service and handler
internal/service/stats.go, internal/handler/stats.go
StatsService owns stats retrieval through an injected DAO, while StatsHandler delegates requests to it.
Stats route wiring
internal/router/router.go
The router stores StatsHandler and routes /api/v1/system/stats through it.
Server startup integration
cmd/ragflow_server.go
Startup constructs the stats service and handler and passes the handler to the router.

Enterprise router hook

Layer / File(s) Summary
Enterprise route registration hook
internal/admin/router.go, internal/admin/router_ee.go
Admin setup invokes RegisterEERouter; the new function currently performs no registration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: ☯️ refactor

Poem

I’m a bunny with stats in a brand-new lane,
Service and handler now hop in the chain.
The router points neatly where numbers should go,
Startup wires the helpers in tow.
An EE hook waits with an empty refrain.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: refactoring system stats into a dedicated service.
Description check ✅ Passed The description includes the required Summary section and clearly states the main intent of moving stats out of system.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN JinHai-CN removed the ci Continue Integration label Jul 20, 2026
@JinHai-CN
JinHai-CN marked this pull request as ready for review July 20, 2026 05:43
@JinHai-CN JinHai-CN added the ci Continue Integration label Jul 20, 2026
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 20, 2026
@JinHai-CN JinHai-CN added ci Continue Integration and removed ci Continue Integration labels Jul 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/service/stats.go`:
- Around line 31-41: Remove the unused systemSettingsDAO field from StatsService
and stop initializing it in NewStatsService; leave the service constructor
returning an otherwise empty StatsService while preserving existing stats
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 557e6a25-ea36-4645-944c-732c2ba94ba9

📥 Commits

Reviewing files that changed from the base of the PR and between 2e39662 and b7b98e8.

📒 Files selected for processing (4)
  • cmd/ragflow_server.go
  • internal/handler/stats.go
  • internal/router/router.go
  • internal/service/stats.go

Comment thread internal/service/stats.go Resolved
Signed-off-by: Jin Hai <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/admin/router_ee.go (1)

26-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Verify the empty EE hook before merging.

RegisterEERouter is called, but its empty implementation registers no routes or side effects. If this stub is required for a separate enterprise implementation, verify that build/overlay contract; otherwise remove this compatibility-only exported API and its caller. As per coding guidelines, prefer deletion over compatibility shims and reduce public surface area unless an external contract requires compatibility.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/admin/router_ee.go` around lines 26 - 27, Verify whether
RegisterEERouter is required by an enterprise build or overlay contract; if not,
remove the empty exported RegisterEERouter function and its caller, reducing the
public API instead of retaining a compatibility stub. If the contract requires
it, preserve the hook and document or enforce the build integration that
supplies its implementation.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/admin/router_ee.go`:
- Around line 26-27: Verify whether RegisterEERouter is required by an
enterprise build or overlay contract; if not, remove the empty exported
RegisterEERouter function and its caller, reducing the public API instead of
retaining a compatibility stub. If the contract requires it, preserve the hook
and document or enforce the build integration that supplies its implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c8305bd1-bc88-44ab-8f1d-7a231197c168

📥 Commits

Reviewing files that changed from the base of the PR and between b7b98e8 and f9bca23.

📒 Files selected for processing (3)
  • internal/admin/router.go
  • internal/admin/router_ee.go
  • internal/service/stats.go

@JinHai-CN
JinHai-CN merged commit 1fdf167 into infiniflow:main Jul 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant