mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge pull request #1020 from guiceolin/add_to_queue_for_scheduled_jobs
Adding 'add to queue' button to the list of scheduled jobs on monitor web interface
This commit is contained in:
commit
76bef8ff5b
20 changed files with 62 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
HEAD
|
||||
-----------
|
||||
|
||||
- Adding button to move scheduled job to main queue [guiceolin, #1020]
|
||||
- fix i18n support resetting saved locale when job is retried [#1011]
|
||||
- log rotation via USR2 now closes the old logger [#1008]
|
||||
|
||||
|
|
|
@ -222,6 +222,17 @@ module Sidekiq
|
|||
@parent.schedule(at, item)
|
||||
end
|
||||
|
||||
def add_to_queue
|
||||
Sidekiq.redis do |conn|
|
||||
results = conn.zrangebyscore('schedule', score, score)
|
||||
conn.zremrangebyscore('schedule', score, score)
|
||||
results.map do |message|
|
||||
msg = Sidekiq.load_json(message)
|
||||
Sidekiq::Client.push(msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def retry
|
||||
raise "Retry not available on jobs not in the Retry queue." unless item["failed_at"]
|
||||
Sidekiq.redis do |conn|
|
||||
|
|
|
@ -251,9 +251,14 @@ module Sidekiq
|
|||
|
||||
post '/scheduled' do
|
||||
halt 404 unless params['key']
|
||||
halt 404 unless params['delete']
|
||||
|
||||
params['key'].each do |key|
|
||||
Sidekiq::ScheduledSet.new.fetch(*parse_params(key)).first.delete
|
||||
job = Sidekiq::ScheduledSet.new.fetch(*parse_params(key)).first
|
||||
if params['delete']
|
||||
job.delete
|
||||
elsif params['add_to_queue']
|
||||
job.add_to_queue
|
||||
end
|
||||
end
|
||||
redirect "#{root_path}scheduled"
|
||||
end
|
||||
|
|
|
@ -172,6 +172,18 @@ class TestApi < Minitest::Test
|
|||
assert_equal 0, q.size
|
||||
end
|
||||
|
||||
it "can move scheduled job to queue" do
|
||||
job_id = ApiWorker.perform_in(100, 1, 'jason')
|
||||
job = Sidekiq::ScheduledSet.new.find_job(job_id)
|
||||
q = Sidekiq::Queue.new
|
||||
job.add_to_queue
|
||||
queued_job = q.find_job(job_id)
|
||||
refute_nil queued_job
|
||||
assert_equal queued_job.jid, job_id
|
||||
job = Sidekiq::ScheduledSet.new.find_job(job_id)
|
||||
assert_nil job
|
||||
end
|
||||
|
||||
it 'can find job by id in sorted sets' do
|
||||
job_id = ApiWorker.perform_in(100, 1, 'jason')
|
||||
job = Sidekiq::ScheduledSet.new.find_job(job_id)
|
||||
|
|
|
@ -178,6 +178,22 @@ class TestWeb < Minitest::Test
|
|||
end
|
||||
end
|
||||
|
||||
it "can move scheduled to default queue" do
|
||||
params = add_scheduled
|
||||
Sidekiq.redis do |conn|
|
||||
assert_equal 1, conn.zcard('schedule')
|
||||
assert_equal 0, conn.zcard('default')
|
||||
post '/scheduled', 'key' => [job_params(*params)], 'add_to_queue' => 'AddToQueue'
|
||||
assert_equal 302, last_response.status
|
||||
assert_equal 'http://example.org/scheduled', last_response.header['Location']
|
||||
assert_equal 0, conn.zcard('schedule')
|
||||
get '/queues/default'
|
||||
assert_equal 200, last_response.status
|
||||
assert_match /#{params[0]['args'][2]}/, last_response.body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it 'can retry all retries' do
|
||||
msg, score = add_retry
|
||||
add_retry
|
||||
|
|
|
@ -24,6 +24,7 @@ da:
|
|||
ShowAll: Vis alle
|
||||
CurrentMessagesInQueue: Nuværende beskeder i <span class='title'>%{queue}</span>
|
||||
Delete: Slet
|
||||
AddToQueue: Tilføj til kø
|
||||
AreYouSureDeleteJob: Er du sikker på at du vil slette dette job?
|
||||
AreYouSureDeleteQueue: Er du sikker på at du vil slette %{queue} køen?
|
||||
Queues: Køer
|
||||
|
|
|
@ -24,6 +24,7 @@ de:
|
|||
ShowAll: Alle anzeigen
|
||||
CurrentMessagesInQueue: Aktuelle Nachrichten in <span class='title'>%{queue}</span>
|
||||
Delete: Löschen
|
||||
AddToQueue: Add to queue
|
||||
AreYouSureDeleteJob: Möchtest du diesen Job wirklich löschen?
|
||||
AreYouSureDeleteQueue: Möchtest du %{queue} wirklich löschen?
|
||||
Queues: Warteschlangen
|
||||
|
|
|
@ -26,6 +26,7 @@ en: # <---- change this to your locale code
|
|||
ShowAll: Show All
|
||||
CurrentMessagesInQueue: Current messages in <span class='title'>%{queue}</span>
|
||||
Delete: Delete
|
||||
AddToQueue: Add to queue
|
||||
AreYouSureDeleteJob: Are you sure you want to delete this job?
|
||||
AreYouSureDeleteQueue: Are you sure you want to delete the %{queue} queue?
|
||||
Queues: Queues
|
||||
|
|
|
@ -24,6 +24,7 @@ es:
|
|||
ShowAll: Mostrar Todo
|
||||
CurrentMessagesInQueue: Mensajes actualmente en <span class='title'>%{queue}</span>
|
||||
Delete: Eliminar
|
||||
AddToQueue: Añadir a fila
|
||||
AreYouSureDeleteJob: ¿Estás seguro de eliminar este trabajo?
|
||||
AreYouSureDeleteQueue: ¿Estás seguro de eliminar la fila %{queue}?
|
||||
Queues: Filas
|
||||
|
|
|
@ -24,6 +24,7 @@ fr:
|
|||
ShowAll: Montrer Tout
|
||||
CurrentMessagesInQueue: Messages actuellement dans <span class='title'>%{queue}</span>
|
||||
Delete: Supprimer
|
||||
AddToQueue: Ajouter à la liste
|
||||
AreYouSureDeleteJob: Êtes-vous certain de vouloir supprimer cette tâche?
|
||||
AreYouSureDeleteQueue: Êtes-vous certain de vouloir supprimer la file %{queue}?
|
||||
Queues: Queues
|
||||
|
|
|
@ -24,6 +24,7 @@ it:
|
|||
ShowAll: Mostra tutti
|
||||
CurrentMessagesInQueue: Messaggi in <span class='title'>%{queue}</span>
|
||||
Delete: Cancella
|
||||
AddToQueue: Aggiungi a coda
|
||||
AreYouSureDeleteJob: Sei sicuro di voler cancellare questo lavoro?
|
||||
AreYouSureDeleteQueue: Sei sicuro di voler cancellare la coda %{queue}?
|
||||
Queues: Code
|
||||
|
|
|
@ -25,6 +25,7 @@ ja:
|
|||
ShowAll: 全て見せる
|
||||
CurrentMessagesInQueue: <span class='title'>%{queue}</span>に メッセージがあります
|
||||
Delete: 削除
|
||||
AddToQueue: キューに追加
|
||||
AreYouSureDeleteJob: このジョブを削除しますか?
|
||||
AreYouSureDeleteQueue: この %{queue} キューを削除しますか?
|
||||
Queues: キュー
|
||||
|
|
|
@ -25,6 +25,7 @@ ko:
|
|||
ShowAll: 모두 보기
|
||||
CurrentMessagesInQueue: <span class='title'>%{queue}</span>에 대기 중인 메시지
|
||||
Delete: 삭제
|
||||
AddToQueue: 큐 추가
|
||||
AreYouSureDeleteJob: 이 작업을 삭제하시겠습니까?
|
||||
AreYouSureDeleteQueue: 이 %{queue} 큐를 삭제하시겠습니까?
|
||||
Queues: 큐
|
||||
|
|
|
@ -25,6 +25,7 @@ nl:
|
|||
ShowAll: Toon alle
|
||||
CurrentMessagesInQueue: Aantal berichten in <span class='title'>%{queue}</span>
|
||||
Delete: Verwijderen
|
||||
AddToQueue: Toevoegen aan wachtrij
|
||||
AreYouSureDeleteJob: Weet u zeker dat u deze taak wilt verwijderen?
|
||||
AreYouSureDeleteQueue: Weet u zeker dat u wachtrij %{queue} wilt verwijderen?
|
||||
Queues: Wachtrijen
|
||||
|
|
|
@ -25,6 +25,7 @@ no:
|
|||
ShowAll: Vis alle
|
||||
CurrentMessagesInQueue: Nåværende melding i <span class='title'>%{queue}</span>
|
||||
Delete: Slett
|
||||
AddToQueue: Legg til i kø
|
||||
AreYouSureDeleteJob: Er du sikker på at du vil slette denne jobben?
|
||||
AreYouSureDeleteQueue: Er du sikker på at du vil slette køen %{queue}?
|
||||
Queues: Køer
|
||||
|
|
|
@ -24,6 +24,7 @@ pl:
|
|||
ShowAll: Pokaż wszystko
|
||||
CurrentMessagesInQueue: Aktualne wiadomości w kolejce <span class='title'>%{queue}</span>
|
||||
Delete: Usuń
|
||||
AddToQueue: dodaj do kolejki
|
||||
AreYouSureDeleteJob: Czy na pewno usunąć to zadanie?
|
||||
AreYouSureDeleteQueue: Czy na pewno usunąć kolejkę %{queue}?
|
||||
Queues: Kolejki
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
ShowAll: Mostrar todos
|
||||
CurrentMessagesInQueue: Mensagens atualmenta na <span class='title'>%{queue}</span>
|
||||
Delete: Apagar
|
||||
AddToQueue: Adicionar à fila
|
||||
AreYouSureDeleteJob: Deseja deletar esta tarefa?
|
||||
AreYouSureDeleteQueue: Deseja deletar a %{queue} fila?
|
||||
Queues: Filas
|
||||
|
|
|
@ -24,6 +24,7 @@ pt:
|
|||
ShowAll: Mostrar todos
|
||||
CurrentMessagesInQueue: Mensagens na fila <span class='title'>%{queue}</span>
|
||||
Delete: Apagar
|
||||
AddToQueue: Adicionar à fila
|
||||
AreYouSureDeleteJob: Tem a certeza que deseja eliminar esta tarefa?
|
||||
AreYouSureDeleteQueue: Tem a certeza que deseja eliminar a fila %{queue}?
|
||||
Queues: Filas
|
||||
|
|
|
@ -24,6 +24,7 @@ ru:
|
|||
ShowAll: Показать все
|
||||
CurrentMessagesInQueue: Текущие сообщения в <span class='title'>%{queue}</span>
|
||||
Delete: Удалить
|
||||
AddToQueue: Добавить в очередь
|
||||
AreYouSureDeleteJob: Вы уверены в том, что хотите удалить задание?
|
||||
AreYouSureDeleteQueue: Вы уверены в том, что хотите удалить очередь %{queue}?
|
||||
Queues: Очереди
|
||||
|
|
|
@ -26,5 +26,6 @@ header.row
|
|||
td= msg['class']
|
||||
td= display_args(msg['args'])
|
||||
input.btn.btn-danger.pull-right type="submit" name="delete" value="#{t('Delete')}"
|
||||
input.btn.btn-danger.pull-right type="submit" name="add_to_queue" value="#{t('AddToQueue')}"
|
||||
- else
|
||||
.alert.alert-success = t('NoScheduledFound')
|
||||
|
|
Loading…
Reference in a new issue