Skip to content

fix: make computeTrend time-independent via injectable now (#7) - #8

Merged
four-bytes-robby merged 1 commit into
mainfrom
fix/7-trend-time-dependence
Sep 5, 2026
Merged

fix: make computeTrend time-independent via injectable now (#7)#8
four-bytes-robby merged 1 commit into
mainfrom
fix/7-trend-time-dependence

Conversation

@four-bytes-robby

@four-bytes-robby four-bytes-robby commented Sep 5, 2026

Copy link
Copy Markdown
Member

fixes issue #7computeTrend gained an optional now param; trend tests now pass a fixed now so they are deterministic (full suite 146/146 green). Closes #7.


Summary by cubic

Makes computeTrend deterministic by accepting an optional now parameter instead of calling new Date() internally, so trend calculations no longer depend on wall-clock time.

Bug Fixes

  • computeTrend now takes an optional now argument; callers who don't pass it keep the previous behavior.
  • Trend tests pass a fixed reference date, making the full suite deterministic and green (146/146).

Written for commit 7ae8383. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Trend calculations now use a consistent reference time, improving result stability across repeated evaluations.
  • Tests

    • Trend behavior is now validated against a fixed reference date, making test outcomes more consistent and reliable.

@four-bytes-robby
four-bytes-robby merged commit 93a4855 into main Sep 5, 2026
2 of 3 checks passed
@four-bytes-robby
four-bytes-robby deleted the fix/7-trend-time-dependence branch September 5, 2026 08:30
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: ffdbe7d0-e206-4fc0-8a58-45d7d63be428

📥 Commits

Reviewing files that changed from the base of the PR and between 13965fa and 7ae8383.

📒 Files selected for processing (2)
  • src/tools/trend.ts
  • tests/trend.test.ts

📝 Walkthrough

Walkthrough

computeTrend now accepts an optional reference date and uses it for both trend windows. Trend tests pass a fixed June 15, 2026 date to remove wall-clock dependence.

Changes

Trend calculation determinism

Layer / File(s) Summary
Injectable trend reference time and deterministic tests
src/tools/trend.ts, tests/trend.test.ts
computeTrend accepts an optional now date and derives both reference dates from it. All trend tests pass a fixed reference date.

Estimated code review effort: 1 (Trivial) | ~5 minutes

✨ 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 fix/7-trend-time-dependence
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/7-trend-time-dependence

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.

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