Cleanup, refactoring, updated transaction

This commit is contained in:
Vokhmin Alexey V 2014-02-25 00:59:20 +04:00
parent fe20a9788a
commit 4838d5e0b8
2 changed files with 6 additions and 4 deletions

View File

@ -8,6 +8,7 @@ class CleanBuildListsQueuesJob
queue = "queue:#{key}"
if redis.llen(queue) == 0
redis.multi do
redis.watch queue
redis.del queue
redis.srem 'queues', key
end

View File

@ -53,12 +53,11 @@ module AbfWorker::ModelHelper
end
def destroy_from_resque_queue
result = Resque::Job.destroy(
Resque::Job.destroy(
worker_queue_with_priority,
worker_queue_class,
abf_worker_args
)
result
end
def worker_queue_with_priority(prefix = true)
@ -88,8 +87,10 @@ module AbfWorker::ModelHelper
return unless is_a?(BuildList)
key = mass_build_id ? MASS_BUILDS_SET : USER_BUILDS_SET
Resque.redis.sadd key, mass_build_id || user_id
Resque.redis.sadd 'queues', worker_queue_with_priority
Resque.redis.pipelined do
Resque.redis.sadd key, mass_build_id || user_id
Resque.redis.sadd 'queues', worker_queue_with_priority
end
end