Skip to content

Commit

Permalink
Have enqueued_at time be nil for jobs that have yet to be enqueued (i…
Browse files Browse the repository at this point in the history
….e., are scheduled).
  • Loading branch information
jonhyman committed Aug 16, 2015
1 parent 7fb504a commit e953794
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/sidekiq/api.rb
Expand Up @@ -312,7 +312,7 @@ def jid
end

def enqueued_at
Time.at(@item['enqueued_at'] || 0).utc
@item['enqueued_at'] ? Time.at(@item['enqueued_at']).utc : nil
end

def created_at
Expand Down
6 changes: 6 additions & 0 deletions test/test_api.rb
Expand Up @@ -207,6 +207,12 @@ class ApiWorker
assert_equal 0, q.size
end

it 'has no enqueued_at time for jobs enqueued in the future' do
job_id = ApiWorker.perform_in(100, 1, 'foo')
job = Sidekiq::ScheduledSet.new.find_job(job_id)
assert_nil job.enqueued_at
end

it 'unwraps delayed jobs' do
ApiWorker.delay.foo(1,2,3)
q = Sidekiq::Queue.new
Expand Down
1 change: 1 addition & 0 deletions web/locales/en.yml
Expand Up @@ -74,3 +74,4 @@ en: # <---- change this to your locale code
QuietAll: Quiet All
PollingInterval: Polling interval
Plugins: Plugins
NotYetEnqueued: Not yet enqueued
2 changes: 1 addition & 1 deletion web/views/_job_info.erb
Expand Up @@ -34,7 +34,7 @@
</tr>
<tr>
<th><%= t('Enqueued') %></th>
<td><%= relative_time(job.enqueued_at) %></td>
<td><%= (enqueued_at = job.enqueued_at) ? relative_time(enqueued_at) : t('NotYetEnqueued') %></td>
</tr>
<% unless retry_extra_items(job).empty? %>
<tr>
Expand Down

0 comments on commit e953794

Please sign in to comment.