From ff3e5ac72e9bb602fc56b730ba355218555ea525 Mon Sep 17 00:00:00 2001 From: Damian Senn Date: Wed, 4 Dec 2024 16:46:18 +0100 Subject: [PATCH] refactor: reduce nesting in github fetch --- lua/pipeline/providers/github/rest/init.lua | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lua/pipeline/providers/github/rest/init.lua b/lua/pipeline/providers/github/rest/init.lua index 50f2362..d166c53 100644 --- a/lua/pipeline/providers/github/rest/init.lua +++ b/lua/pipeline/providers/github/rest/init.lua @@ -207,17 +207,19 @@ function GithubRestProvider:dispatch(pipeline) store.update_state(function(state) state.error = err and err.message or nil - state.runs = utils.group_by( - function(run) - return run.pipeline_id - end, - utils.uniq(function(run) - return run.run_id - end, { - unpack(runs), - unpack(vim.iter(state.runs):flatten():totable()), - }) - ) + if not state.error then + state.runs = utils.group_by( + function(run) + return run.pipeline_id + end, + utils.uniq(function(run) + return run.run_id + end, { + unpack(runs), + unpack(vim.iter(state.runs):flatten():totable()), + }) + ) + end end) end, }