Skip to content

Commit

Permalink
fix lock & changelog times on web interface (#762)
Browse files Browse the repository at this point in the history
* fix lock & changelog times for nil.to_f

* rubocop -a

---------

Co-authored-by: Mikael Henriksson <[email protected]>
  • Loading branch information
JeremiahChurch and mhenrixon authored Mar 13, 2023
1 parent 763948b commit 5e81c04
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/sidekiq_unique_jobs/lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ def self.create(digest, job_id, lock_info = {})
# @param [Timstamp, Float] time nil optional timestamp to initiate this lock with
#
def initialize(key, time: nil)
@key = get_key(key)
@created_at = time.is_a?(Float) ? time : time.to_f
@key = get_key(key)
time = time.is_a?(Float) ? time : time.to_f
return unless time.nonzero?

@created_at = time
end

#
Expand Down
2 changes: 2 additions & 0 deletions lib/sidekiq_unique_jobs/web/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def relative_time(time)
# @return [String] a html safe string with relative time information
#
def safe_relative_time(time)
return unless time

time = parse_time(time)

relative_time(time)
Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/web/views/changelogs.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<tbody>
<% @changelogs.each do |changelog| %>
<tr class="changelog-row">
<td><%= "bogus" %></td>
<td><%= safe_relative_time(changelog['time']) || "bogus" %></td>
<td><%= changelog["digest"] %></td>
<td><%= changelog["script"] %></td>
<td><%= changelog["job_id"] %></td>
Expand Down

0 comments on commit 5e81c04

Please sign in to comment.