-
Notifications
You must be signed in to change notification settings - Fork 40
Fix Bug Where You Can't See Days in Hours #781
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
Conversation
Once reaching 24hrs of time or 86400 seconds it would not display those 24hrs. My fix makes it show hours above 24 if there include_days is false and if it true it simplifies it into days aswell, and following the current formatting it hides the hours, if zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in the format_seconds helper method where hours would not accumulate beyond 24 when include_days is set to false. Previously, hours would max out at 23h even for durations exceeding 24 hours when days were not being displayed.
Key Changes:
- Modified hours calculation to accumulate all hours when
include_daysis false, instead of resetting after 24 hours - Updated the hours display condition to show hours when there are accumulated days but
include_daysis false
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| parts << "#{hours}h" if hours > 0 || (include_days && days > 0) | ||
| parts << "#{hours}h" if hours > 0 || (!include_days && days > 0) | ||
| parts << "#{minutes}m" if minutes > 0 || parts.any? | ||
|
|
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected on this line. This should be removed to maintain consistent code style.
| end | ||
|
|
||
| def format_seconds(seconds, include_days: false) | ||
| def format_seconds(seconds, include_days = false) |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing from keyword argument syntax (include_days:) to positional argument syntax (include_days =) is a breaking API change. Existing calls using include_days: true will fail. Looking at the codebase, there are multiple calls in app/views/admin/fulfillment_dashboard/index.html.erb using the keyword argument syntax (include_days: true) that will break with this change.
| def format_seconds(seconds, include_days = false) | |
| def format_seconds(seconds, include_days = false, **options) | |
| include_days = options.fetch(:include_days, include_days) |
| days = seconds / 86400 | ||
| hours = (seconds % 86400) / 3600 | ||
| hours = include_days ? (seconds % 86400) / 3600 : seconds / 3600 | ||
|
|
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected on this line. This should be removed to maintain consistent code style.
I think it this bit
/app/helper/application_helper.rb
I'm presuming include_days is false which means hours is put only until it reaches 24hr
parts << "#{hours}h" if hours > 0 || (include_days && days > 0)where it should beparts << "#{hours}h" if hours > 0 || (! include_days && days > 0)My Version is: