diff --git a/lib/qless/lua/qless-lib.lua b/lib/qless/lua/qless-lib.lua index 08c7ae7d..a83d9988 100644 --- a/lib/qless/lua/qless-lib.lua +++ b/lib/qless/lua/qless-lib.lua @@ -1,4 +1,4 @@ --- Current SHA: 525c39000dc71df53a3502491cb4daf0e1128f1d +-- Current SHA: 5e998615e96d35c55a79458a77527687ef55733d -- This is a generated file ------------------------------------------------------------------------------- -- Forward declarations to make everything happy @@ -258,7 +258,7 @@ function Qless.tag(now, command, ...) -- Otherwise, add the job to the sorted set with that tags for i=2,#arg do local tag = arg[i] - if _tags[tag] == nil then + if _tags[tag] == nil or _tags[tag] == false then _tags[tag] = true table.insert(tags, tag) end @@ -333,7 +333,7 @@ function Qless.cancel(...) -- make sure that this operation will be ok for i, jid in ipairs(arg) do for j, dep in ipairs(dependents[jid]) do - if dependents[dep] == nil then + if dependents[dep] == nil or dependents[dep] == false then error('Cancel(): ' .. jid .. ' is a dependency of ' .. dep .. ' but is not mentioned to be canceled') end @@ -1144,7 +1144,7 @@ function QlessJob:priority(priority) -- Get the queue the job is currently in, if any local queue = redis.call('hget', QlessJob.ns .. self.jid, 'queue') - if queue == nil then + if queue == nil or queue == false then -- If the job doesn't exist, throw an error error('Priority(): Job ' .. self.jid .. ' does not exist') elseif queue == '' then @@ -1177,7 +1177,7 @@ end function QlessJob:timeout(now) local queue_name, state, worker = unpack(redis.call('hmget', QlessJob.ns .. self.jid, 'queue', 'state', 'worker')) - if queue_name == nil then + if queue_name == nil or queue_name == false then error('Timeout(): Job does not exist') elseif state ~= 'running' then error('Timeout(): Job ' .. self.jid .. ' not running') @@ -1261,7 +1261,7 @@ function QlessJob:history(now, what, item) -- We'll always keep the first item around local obj = redis.call('lpop', QlessJob.ns .. self.jid .. '-history') redis.call('ltrim', QlessJob.ns .. self.jid .. '-history', -count + 2, -1) - if obj ~= nil then + if obj ~= nil and obj ~= false then redis.call('lpush', QlessJob.ns .. self.jid .. '-history', obj) end end @@ -1728,8 +1728,8 @@ function QlessQueue:put(now, worker, jid, klass, raw_data, delay, ...) -- Now find what's in the original, but not the new local original = redis.call( 'smembers', QlessJob.ns .. jid .. '-dependencies') - for _, dep in pairs(original) do - if new[dep] == nil then + for _, dep in pairs(original) do + if new[dep] == nil or new[dep] == false then -- Remove k as a dependency redis.call('srem', QlessJob.ns .. dep .. '-dependents' , jid) redis.call('srem', QlessJob.ns .. jid .. '-dependencies', dep) @@ -2347,8 +2347,8 @@ function QlessRecurringJob:tag(...) for i,v in ipairs(tags) do _tags[v] = true end -- Otherwise, add the job to the sorted set with that tags - for i=1,#arg do if _tags[arg[i]] == nil then table.insert(tags, arg[i]) end end - + for i=1,#arg do if _tags[arg[i]] == nil or _tags[arg[i]] == false then table.insert(tags, arg[i]) end end + tags = cjson.encode(tags) redis.call('hset', 'ql:r:' .. self.jid, 'tags', tags) return tags diff --git a/lib/qless/lua/qless.lua b/lib/qless/lua/qless.lua index ae140ce8..c4be648e 100644 --- a/lib/qless/lua/qless.lua +++ b/lib/qless/lua/qless.lua @@ -1,4 +1,4 @@ --- Current SHA: 525c39000dc71df53a3502491cb4daf0e1128f1d +-- Current SHA: 4bff9c77c7367b128c7474517a086cc44329cb4c -- This is a generated file local Qless = { ns = 'ql:' @@ -150,7 +150,7 @@ function Qless.tag(now, command, ...) for i=2,#arg do local tag = arg[i] - if _tags[tag] == nil then + if _tags[tag] == nil or _tags[tag] == false then _tags[tag] = true table.insert(tags, tag) end @@ -214,7 +214,7 @@ function Qless.cancel(...) for i, jid in ipairs(arg) do for j, dep in ipairs(dependents[jid]) do - if dependents[dep] == nil then + if dependents[dep] == nil or dependents[dep] == false then error('Cancel(): ' .. jid .. ' is a dependency of ' .. dep .. ' but is not mentioned to be canceled') end @@ -823,7 +823,7 @@ function QlessJob:priority(priority) local queue = redis.call('hget', QlessJob.ns .. self.jid, 'queue') - if queue == nil then + if queue == nil or queue == false then error('Priority(): Job ' .. self.jid .. ' does not exist') elseif queue == '' then redis.call('hset', QlessJob.ns .. self.jid, 'priority', priority) @@ -850,7 +850,7 @@ end function QlessJob:timeout(now) local queue_name, state, worker = unpack(redis.call('hmget', QlessJob.ns .. self.jid, 'queue', 'state', 'worker')) - if queue_name == nil then + if queue_name == nil or queue_name == false then error('Timeout(): Job does not exist') elseif state ~= 'running' then error('Timeout(): Job ' .. self.jid .. ' not running') @@ -921,7 +921,7 @@ function QlessJob:history(now, what, item) if count > 0 then local obj = redis.call('lpop', QlessJob.ns .. self.jid .. '-history') redis.call('ltrim', QlessJob.ns .. self.jid .. '-history', -count + 2, -1) - if obj ~= nil then + if obj ~= nil and obj ~= false then redis.call('lpush', QlessJob.ns .. self.jid .. '-history', obj) end end @@ -1266,8 +1266,8 @@ function QlessQueue:put(now, worker, jid, klass, raw_data, delay, ...) local original = redis.call( 'smembers', QlessJob.ns .. jid .. '-dependencies') - for _, dep in pairs(original) do - if new[dep] == nil then + for _, dep in pairs(original) do + if new[dep] == nil or new[dep] == false then redis.call('srem', QlessJob.ns .. dep .. '-dependents' , jid) redis.call('srem', QlessJob.ns .. jid .. '-dependencies', dep) end @@ -1739,9 +1739,9 @@ function QlessRecurringJob:tag(...) tags = cjson.decode(tags) local _tags = {} for i,v in ipairs(tags) do _tags[v] = true end - - for i=1,#arg do if _tags[arg[i]] == nil then table.insert(tags, arg[i]) end end - + + for i=1,#arg do if _tags[arg[i]] == nil or _tags[arg[i]] == false then table.insert(tags, arg[i]) end end + tags = cjson.encode(tags) redis.call('hset', 'ql:r:' .. self.jid, 'tags', tags) return tags