Skip to content

Refactor rate limit time calculation and organize imports#319

Merged
rainxchzed merged 1 commit intomainfrom
rate-limit-time-fix
Mar 11, 2026
Merged

Refactor rate limit time calculation and organize imports#319
rainxchzed merged 1 commit intomainfrom
rate-limit-time-fix

Conversation

@rainxchzed
Copy link
Copy Markdown
Member

@rainxchzed rainxchzed commented Mar 11, 2026

  • Update RateLimitInfo.timeUntilReset() to use Instant and Clock.System.now() for more accurate duration calculation.
  • Fix an issue where resetTimestamp was treated as milliseconds instead of seconds.
  • Organize and clean up imports in TimeFormatters.kt.

Summary by CodeRabbit

  • Refactor
    • Improved internal time calculation logic for rate limit handling using updated time representations.
    • Code organization and import structure optimizations.

- Update `RateLimitInfo.timeUntilReset()` to use `Instant` and `Clock.System.now()` for more accurate duration calculation.
- Fix an issue where `resetTimestamp` was treated as milliseconds instead of seconds.
- Organize and clean up imports in `TimeFormatters.kt`.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 11, 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: ab5d845f-34ce-44bd-87ee-8516f906e315

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 06d89ce and fd3dccc.

πŸ“’ Files selected for processing (2)
  • core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/model/RateLimitInfo.kt
  • core/presentation/src/commonMain/kotlin/zed/rainxch/core/presentation/utils/TimeFormatters.kt

Walkthrough

Updates time calculation in RateLimitInfo to use Instant-based approach instead of epoch-milliseconds, and reorders imports in TimeFormatters. No changes to public APIs or method signatures.

Changes

Cohort / File(s) Summary
Time Calculation Refactoring
core/domain/.../RateLimitInfo.kt
Replaces epoch-milliseconds based time calculation with Instant-based approach in timeUntilReset(). Adds kotlin.time.Instant import and computes duration between reset Instant and current time, coerced to non-negative.
Import Organization
core/presentation/.../TimeFormatters.kt
Reorders import statement by moving resource imports after stringResource imports.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 Whiskers twitching at the clock so fine,
We swap our epochs for Instant divine,
Imports now tidy, in proper array,
Hopping through time in a cleaner way! πŸ•βœ¨

πŸš₯ 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 changes: refactoring rate limit time calculation using Instant and organizing imports in TimeFormatters.kt.

✏️ 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
  • Commit unit tests in branch rate-limit-time-fix

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

@rainxchzed rainxchzed merged commit 2bac18d into main Mar 11, 2026
1 check passed
@rainxchzed rainxchzed deleted the rate-limit-time-fix branch March 11, 2026 17:58
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