Skip to content

Conversation

@Acidicts
Copy link
Contributor

@Acidicts Acidicts commented Jan 3, 2026

I think it this bit

/app/helper/application_helper.rb

def format_seconds(seconds, include_days: false)
    return "0s" if seconds.nil? || seconds <= 0

    days = seconds / 86400
    hours = (seconds % 86400) / 3600
    minutes = (seconds % 3600) / 60
    secs = seconds % 60

    parts = []
    parts << "#{days}d" if include_days && days > 0
    parts << "#{hours}h" if hours > 0 || (include_days && days > 0)
    parts << "#{minutes}m" if minutes > 0 || parts.any?
    parts << "#{secs}s" if parts.empty?

    parts.join(" ")
  end

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 be parts << "#{hours}h" if hours > 0 || (! include_days && days > 0)

My Version is:

def format_seconds(seconds, include_days = false)
    return "0s" if seconds.nil? || seconds <= 0

    days = seconds / 86400
    hours = include_days ? (seconds % 86400) / 3600 : seconds / 3600
    
    minutes = (seconds % 3600) / 60
    secs = seconds % 60

    parts = []
    parts << "#{days}d" if include_days && days > 0
    parts << "#{hours}h" if hours > 0 || (!include_days && days > 0)
    parts << "#{minutes}m" if minutes > 0 || parts.any?
    
    parts << "#{secs}s" if parts.empty?

    parts.join(" ")
end

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.
Removed 'workflow_dispatch' trigger from CI workflow.
Removed autocorrect option from rubocop linting step.
Copilot AI review requested due to automatic review settings January 3, 2026 19:50
@Acidicts Acidicts marked this pull request as draft January 3, 2026 19:51
Copy link
Contributor

Copilot AI left a 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 where hours would "disappear" from the time display after exceeding 24 hours. The issue occurred when include_days was false - the function was calculating hours as a remainder after removing days (hours % 24), rather than showing total hours.

Key Changes:

  • Modified hours calculation to show total hours when include_days is false, and hours within a day when include_days is true
  • Updated the condition for displaying hours to properly handle both modes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

end

def format_seconds(seconds, include_days: false)
def format_seconds(seconds, include_days = false)
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

Changing the parameter from a keyword argument (include_days:) to a positional argument (include_days =) breaks existing code. The codebase has multiple calls using the keyword argument syntax (e.g., format_seconds(data[:aho], include_days: true) in app/views/admin/fulfillment_dashboard/index.html.erb). These calls will fail with an ArgumentError after this change. Keep the keyword argument syntax to maintain backward compatibility.

Suggested change
def format_seconds(seconds, include_days = false)
def format_seconds(seconds, include_days = false, **kwargs)
include_days = kwargs.fetch(:include_days, include_days)

Copilot uses AI. Check for mistakes.
days = seconds / 86400
hours = (seconds % 86400) / 3600
hours = include_days ? (seconds % 86400) / 3600 : seconds / 3600

Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

This blank line change doesn't serve a clear purpose and deviates from the original formatting. Consider keeping the original whitespace structure for consistency unless there's a specific style guide requirement.

Copilot uses AI. Check for mistakes.
minutes = (seconds % 3600) / 60
secs = seconds % 60

Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

This blank line change doesn't serve a clear purpose and deviates from the original formatting. Consider keeping the original whitespace structure for consistency unless there's a specific style guide requirement.

Copilot uses AI. Check for mistakes.
@Acidicts Acidicts marked this pull request as ready for review January 3, 2026 19:57
@Acidicts Acidicts changed the title Fix Bug that makes hours "disappear" Fix Bug that makes hours visually "disappear" Jan 4, 2026
@maxwofford
Copy link
Member

I like the time changes, but your PR touches a bunch of other stuff around CI runs. can you just cherrypick the change that should be made so i can merge that?

maxwofford added a commit that referenced this pull request Jan 5, 2026
Co-Authored-By: Acidicts <[email protected]>
@maxwofford maxwofford mentioned this pull request Jan 5, 2026
@maxwofford
Copy link
Member

I just moved this to #796!

@maxwofford maxwofford closed this Jan 5, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 5, 2026
* Reapply #782

Co-Authored-By: Acidicts <[email protected]>

* Add example usage of format_seconds

---------

Co-authored-by: Acidicts <[email protected]>
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.

2 participants