diff --git a/lib/sidekiq_unique_jobs/lock.rb b/lib/sidekiq_unique_jobs/lock.rb index e6cb8985..3be0a65e 100644 --- a/lib/sidekiq_unique_jobs/lock.rb +++ b/lib/sidekiq_unique_jobs/lock.rb @@ -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 # diff --git a/lib/sidekiq_unique_jobs/web/helpers.rb b/lib/sidekiq_unique_jobs/web/helpers.rb index fde31aa3..0cb27403 100644 --- a/lib/sidekiq_unique_jobs/web/helpers.rb +++ b/lib/sidekiq_unique_jobs/web/helpers.rb @@ -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) diff --git a/lib/sidekiq_unique_jobs/web/views/changelogs.erb b/lib/sidekiq_unique_jobs/web/views/changelogs.erb index 64794b8f..fe0e7009 100644 --- a/lib/sidekiq_unique_jobs/web/views/changelogs.erb +++ b/lib/sidekiq_unique_jobs/web/views/changelogs.erb @@ -42,7 +42,7 @@ <% @changelogs.each do |changelog| %> - <%= "bogus" %> + <%= safe_relative_time(changelog['time']) || "bogus" %> <%= changelog["digest"] %> <%= changelog["script"] %> <%= changelog["job_id"] %>