Skip to content

don't round to 0 if 0 isn't within bounds#4517

Open
lsabor wants to merge 1 commit intomainfrom
quickfix/ticks2
Open

don't round to 0 if 0 isn't within bounds#4517
lsabor wants to merge 1 commit intomainfrom
quickfix/ticks2

Conversation

@lsabor
Copy link
Contributor

@lsabor lsabor commented Mar 20, 2026

fixes bug where a sufficiently large range with lower bound close to but not equal to 0 causes the second pixel hover state to display as 0 even though 0 isn't within bounds.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced number formatting with improved zero-detection logic. The abbreviation function now evaluates whether numeric scaling ranges include zero to determine proper value display, replacing previous detection methods for more consistent numeric formatting throughout the application.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 89cfa0af-27b3-4bf9-a000-59249d43f492

📥 Commits

Reviewing files that changed from the base of the PR and between f3e4d51 and f45b29d.

📒 Files selected for processing (1)
  • front_end/src/utils/formatters/number.ts

📝 Walkthrough

Walkthrough

The abbreviatedNumber function's zero-detection logic for scaling parameters was updated. Instead of checking whether zero_point is nil, it now requires the scaling range to straddle zero (range_min < 0 < range_max), changing when the function returns "0".

Changes

Cohort / File(s) Summary
Zero-detection Logic Update
front_end/src/utils/formatters/number.ts
Modified abbreviatedNumber's zero-detection condition for scaling parameter; replaced zero_point nil check with requirement that range straddles zero (range_min < 0 and 0 < range_max).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • ncarazon

Poem

🐰 A zero once guarded by a point so small,
Now balanced on ranges, straddling them all,
The number formatter hops with new precision,
Less checking, more ranging—a wise digit decision! ✨

🚥 Pre-merge checks | ✅ 2
✅ 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 directly and clearly summarizes the main change: preventing rounding to 0 when 0 is outside the valid bounds of the scaling range.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch quickfix/ticks2
📝 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.

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4517-quickfix-ticks2-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:quickfix-ticks2-f45b29d
🗄️ PostgreSQL NeonDB branch preview/pr-4517-quickfix-ticks2
Redis Fly Redis mtc-redis-pr-4517-quickfix-ticks2

Details

  • Commit: f45b29ddfb70d0555f03b47bdd364a47edf37b5b
  • Branch: quickfix/ticks2
  • Fly App: metaculus-pr-4517-quickfix-ticks2

ℹ️ Preview Environment Info

Isolation:

  • PostgreSQL and Redis are fully isolated from production
  • Each PR gets its own database branch and Redis instance
  • Changes pushed to this PR will trigger a new deployment

Limitations:

  • Background workers and cron jobs are not deployed in preview environments
  • If you need to test background jobs, use Heroku staging environments

Cleanup:

  • This preview will be automatically destroyed when the PR is closed

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