Skip to content

fix: Update service to use display_index as the main sort order#60

Merged
hamster1963 merged 3 commits intohamster1963:mainfrom
laosan-xx:main
Feb 25, 2026
Merged

fix: Update service to use display_index as the main sort order#60
hamster1963 merged 3 commits intohamster1963:mainfrom
laosan-xx:main

Conversation

@laosan-xx
Copy link
Contributor

@laosan-xx laosan-xx commented Feb 25, 2026

Backend Update: Sorting Optimization

  1. Primary Sort: display_index descending (larger values first). Treat undefined values as 0.

  2. Secondary Sort: monitor_id ascending (preserving original logic).

Summary by CodeRabbit

  • New Features

    • Improved monitor ordering in charts: monitors now follow a richer, more predictable display order (better handling of missing or ambiguous items).
  • Style

    • Reformatted translation files for consistent indentation and formatting (no changes to translations' text).

@github-actions
Copy link

Linting and formatting issues were automatically fixed. Please review the changes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b22d823 and bb315db.

📒 Files selected for processing (1)
  • src/types/nezha-api.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/types/nezha-api.ts

📝 Walkthrough

Walkthrough

Adds an optional display_index to Nezha monitors and updates NetworkChart to use a monitorInfoByName map (id + displayIndex) for sorting chart keys by displayIndex (desc), then id, with locale-based fallback when info is missing.

Changes

Cohort / File(s) Summary
API Type Enhancement
src/types/nezha-api.ts
Added optional display_index?: number to NezhaMonitor.
Chart Sorting Logic
src/components/NetworkChart.tsx
Replaced simple monitor_id lookup with monitorInfoByName (stores id and displayIndex); sorting now prefers displayIndex (descending) then id, and falls back to locale string comparison when monitor info is absent. Updated chartDataKey derivation and downstream usage.
Locale JSON Reformatting
src/locales/gl/translation.json, src/locales/uk/translation.json
Whitespace/indentation reformatting only; no semantic changes to keys or values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled through the index trail,
Found ordering hidden in a tale,
I tucked each monitor in its place,
Now charts parade with tidy grace 🥕📊

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating the service to use display_index as the primary sort order for monitors, which aligns with the core modifications in NetworkChart.tsx and the NezhaMonitor interface.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@src/types/nezha-api.ts`:
- Line 96: Make the display_index field optional in the type declaration in
src/types/nezha-api.ts (change to display_index?: number) so missing backend
values are not hidden by the type system, and update any consumers that read
display_index (places that access .display_index) to default to 0 (e.g., use
nullish coalescing or defaulting in constructors/mappers) so undefined is
handled as 0 at runtime.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b030cd4 and 1f8e6a7.

📒 Files selected for processing (2)
  • src/components/NetworkChart.tsx
  • src/types/nezha-api.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Owner

@hamster1963 hamster1963 left a comment

Choose a reason for hiding this comment

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

LGTM

@hamster1963 hamster1963 merged commit eceadb6 into hamster1963:main Feb 25, 2026
3 checks 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.

3 participants