Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct duration formatting logic #643

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

BelKed
Copy link
Contributor

@BelKed BelKed commented Feb 21, 2025

  



Important

Fixes duration formatting in seconds_to_duration and adds unit tests for various cases.

  • Behavior:
    • Fixes seconds_to_duration in time.ts to correctly format durations, ensuring minutes are included only when hours are present.
  • Tests:
    • Adds time.test.js with unit tests for seconds_to_duration, covering various cases like 8145, 3630, 1830, 60, and 30 seconds.

This description was created by Ellipsis for 8c3f995. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to 8c3f995 in 1 minute and 11 seconds

More details
  • Looked at 52 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. src/util/time.ts:16
  • Draft comment:
    Good update: The new logic always shows minutes when hours > 0 (even if 0) to meet test expectations. Consider a comment explaining that the minute value is intentionally displayed (e.g. '0m') for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. src/util/time.ts:14
  • Draft comment:
    Consider renaming variable 'l' to a more descriptive name (e.g. 'parts') for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
3. test/unit/time.test.js:1
  • Draft comment:
    Test cases are comprehensive and cover edge cases as well as usual durations.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. src/util/time.ts:16
  • Draft comment:
    New logic now always includes minutes when hours > 0 (e.g. 3630 sec → '1h 0m 30s'), matching test expectations.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is purely informative, describing a change in logic and how it matches test expectations. It doesn't suggest any code changes or ask for confirmation on specific intentions.
5. src/util/time.ts:17
  • Draft comment:
    Consider using template literals for clarity (e.g. ${hrs}h) instead of string concatenation.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
6. test/unit/time.test.js:24
  • Draft comment:
    Tests are clear; consider adding edge cases (e.g. 0 seconds, exactly 3600 seconds) for broader coverage.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None

Workflow ID: wflow_VmvAjkU8uoF79vxU


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.76%. Comparing base (53cbaaa) to head (d2a7caa).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #643      +/-   ##
==========================================
+ Coverage   26.15%   26.76%   +0.61%     
==========================================
  Files          28       28              
  Lines        1652     1655       +3     
  Branches      293      280      -13     
==========================================
+ Hits          432      443      +11     
- Misses       1161     1186      +25     
+ Partials       59       26      -33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ErikBjare ErikBjare merged commit 2b14364 into ActivityWatch:master Feb 21, 2025
8 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.

Minutes-part of time format not shown when it is zero
2 participants