Skip to content

feat: add week duration support to parse_duration_secs#2324

Merged
btucker merged 2 commits intomainfrom
task-9-task
Apr 5, 2026
Merged

feat: add week duration support to parse_duration_secs#2324
btucker merged 2 commits intomainfrom
task-9-task

Conversation

@btucker
Copy link
Copy Markdown
Owner

@btucker btucker commented Apr 3, 2026

Summary

  • Add "w" (week) suffix to parse_duration_secs, so users can use --since 1w or --since 2w with channel.read
  • Add unit test for week parsing (1w = 604800s, 2w = 1209600s)
  • Update doc comment to include week example

Test plan

  • Added weeks test case asserting correct conversion
  • Confirmed test fails before fix, passes after
  • All existing parse_duration_secs tests still pass
  • cargo clippy clean

Closes !9

🌃 Co-built with Midtown

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10afd573ea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/daemon_v2/rpc/handlers.rs Outdated
"m" => Some(n * 60),
"h" => Some(n * 3600),
"d" => Some(n * 86400),
"w" => Some(n * 604800),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard week conversion against integer overflow

The new "w" branch computes n * 604800 without overflow checks, so a large user-supplied since like "30000000000000w" can overflow (u64 panic in debug builds, wrap in release) and produce a bad cutoff or crash channel.read. Since this parser already returns Option, overflow should map to None via checked_mul rather than silently overflowing.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

@btucker btucker left a comment

Choose a reason for hiding this comment

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

Clean, minimal change. Correctness and test coverage look good.

One minor observation: parse_duration_secs uses split_at(len - 1) which assumes a single-character suffix. This works fine for w, but if someone later wants multi-char suffixes (e.g., "mo" for months), the parser would need restructuring. Not a problem for this PR — just noting for future reference.

No issues found. LGTM.

🌃 Co-built with Midtown

@btucker btucker enabled auto-merge (squash) April 4, 2026 02:15
@btucker
Copy link
Copy Markdown
Owner Author

btucker commented Apr 5, 2026

Codex P2 (overflow guard) is already addressed in this PR — all multiplications use checked_mul (including the new "w" branch), and there are explicit overflow tests for each suffix. The review may have been generated against an earlier revision.

@btucker
Copy link
Copy Markdown
Owner Author

btucker commented Apr 5, 2026

/rebase

btucker and others added 2 commits April 5, 2026 10:52
Add "w" suffix to parse_duration_secs so users can specify durations
like "1w" or "2w" for the channel.read `since` parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use checked_mul for all duration suffix multiplications (m, h, d, w)
so that large user-supplied values return None instead of panicking
in debug or wrapping in release. Updated doc comment to document the
overflow behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@btucker btucker merged commit 05897b0 into main Apr 5, 2026
11 checks passed
@btucker btucker deleted the task-9-task branch April 5, 2026 15:55
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.95%. Comparing base (08fca38) to head (195db0c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2324      +/-   ##
==========================================
+ Coverage   63.89%   63.95%   +0.05%     
==========================================
  Files         100      100              
  Lines       38581    38582       +1     
==========================================
+ Hits        24653    24675      +22     
+ Misses      13928    13907      -21     
Files with missing lines Coverage Δ
src/daemon_v2/rpc/handlers.rs 86.71% <100.00%> (+0.01%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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