Skip to content

Commit

Permalink
refactor: get job attributes ones
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Dec 4, 2024
1 parent 94139c7 commit 65cedab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/commands/includes/removeDeduplicationKey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
Function to remove deduplication key.
]]

local function removeDeduplicationKey(prefixKey, jobKey)
local deduplicationId = rcall("HGET", jobKey, "deid")
local function removeDeduplicationKey(prefixKey, jobKey, deduplicationId)
if deduplicationId then
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
rcall("DEL", deduplicationKey)
Expand Down
6 changes: 4 additions & 2 deletions src/commands/includes/removeJob.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
local jobKey = baseKey .. jobId
removeParentDependencyKey(jobKey, hard, nil, baseKey)
local jobAttributes = rcall("HMGET", jobKey, "deid", "chkey")

if shouldRemoveDeduplicationKey then
removeDeduplicationKey(baseKey, jobKey)
removeDeduplicationKey(baseKey, jobKey, jobAttributes[1])
end
removeChainKeyIfNeeded(rcall("HGET", jobKey, "chkey"), jobKey)
removeChainKeyIfNeeded(jobAttributes[2], jobKey)
removeJobKeys(jobKey)
end
4 changes: 3 additions & 1 deletion src/commands/removeJob-2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ local function removeJob(prefix, jobId, parentKey, removeChildren)

local prev = removeJobFromAnyState(prefix, jobId)

local jobAttributes = rcall("HMGET", jobKey, "deid", "chkey")

removeDeduplicationKey(prefix, jobKey)
removeChainKeyIfNeeded(rcall("HGET", jobKey, "chkey"), jobKey)
removeChainKeyIfNeeded(jobAttributes[2], jobKey, jobAttributes[1])
if removeJobKeys(jobKey) > 0 then
local maxEvents = getOrSetMaxEvents(KEYS[2])
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed", "jobId", jobId, "prev",
Expand Down

0 comments on commit 65cedab

Please sign in to comment.