Skip to content

fix: stats page NaN in total words, sort languages alphabetically#170

Merged
Hugo0 merged 1 commit intomainfrom
fix/stats-page-nan
Mar 15, 2026
Merged

fix: stats page NaN in total words, sort languages alphabetically#170
Hugo0 merged 1 commit intomainfrom
fix/stats-page-nan

Conversation

@Hugo0
Copy link
Owner

@Hugo0 Hugo0 commented Mar 15, 2026

Summary

  • NaN fix: Template referenced lang.n_supplement which doesn't exist in the API response, causing n_words + undefined = NaN for every language row
  • Sort fix: Languages now sorted alphabetically by name instead of by word count
  • Badge fix: "curated" badge checked non-existent has_schedule field, now uses n_daily > 0

Test plan

  • Visit /stats — Total Words column should show numbers, not NaN
  • Languages should be in alphabetical order (Arabic, Azerbaijani, Bengali...)
  • "curated" badge should appear next to languages with daily word pools

Summary by CodeRabbit

  • Updates
    • Updated criteria for displaying the "curated" badge in the All Languages table
    • Modified the Total Words calculation in statistics displays
    • Language list now sorted alphabetically instead of by word count

- Fix NaN: template referenced non-existent n_supplement field, now uses
  n_words directly (matches API response)
- Fix "curated" badge: used non-existent has_schedule field, now checks
  n_daily > 0
- Sort language table alphabetically by name instead of by word count
@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6442e334-f2b4-4f91-b604-d848fc36e6a9

📥 Commits

Reviewing files that changed from the base of the PR and between 52331ec and 20192ff.

📒 Files selected for processing (2)
  • pages/stats.vue
  • server/api/stats.get.ts

📝 Walkthrough

Walkthrough

The statistics page adjusts the curated badge display condition and recalculates the total word count to exclude supplementary words. The API endpoint now sorts languages lexicographically by name instead of by word count in descending order.

Changes

Cohort / File(s) Summary
Frontend Statistics Display
pages/stats.vue
Modified curated badge visibility to trigger on lang.n_daily > 0 instead of lang.has_schedule. Changed Total Words column to display only lang.n_words without the supplement value.
API Language Sorting
server/api/stats.get.ts
Updated langStats sort order from descending word count (n_words) to lexicographic name order using localeCompare.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 The languages now line up neat,
Arranged by name in alphabetic beat,
Curated badges shine more bright,
When daily words reflect the light,
No supplements to pad the count—
Just honest numbers that amount!

✨ 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
  • Commit unit tests in branch fix/stats-page-nan
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@Hugo0 Hugo0 merged commit eff883d into main Mar 15, 2026
5 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.

1 participant