Skip to content

Commit

Permalink
check main function correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushgaud committed Nov 15, 2023
1 parent d22bfdc commit 3b5d3fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
43 changes: 22 additions & 21 deletions src/wrike_ist/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,31 @@
(if-let [pr (.-pull_request payload)]
(loop [links (extract-details pr)]
(when-let [{:keys [state] :as details} (first links)]
(-> (case state
:draft
(js/Promise.all
[(wrike/check-valid-task details)
(wrike/link-pr details)])
(let [check-valid-task-promise (wrike/check-valid-task details)]
(-> (case state
:draft
(js/Promise.all
[(wrike/link-pr details)
check-valid-task-promise])

:open
(js/Promise.all
[(wrike/check-valid-task details)
(wrike/link-pr details)
(wrike/progress-task details (core/getInput "opened"))])
:open
(js/Promise.all
[(wrike/link-pr details)
(wrike/progress-task details (core/getInput "opened"))
check-valid-task-promise])

:merged
(js/Promise.all
[(wrike/check-valid-task details)
(wrike/complete-task details (core/getInput "merged"))])
:merged
(js/Promise.all
[(wrike/complete-task details (core/getInput "merged"))
check-valid-task-promise])

:closed
(js/Promise.all
[(wrike/check-valid-task details)
(wrike/cancel-task details (core/getInput "closed"))])
:closed
(js/Promise.all
[(wrike/cancel-task details (core/getInput "closed"))
check-valid-task-promise])

;; else ignore
(js/Promise.resolve))
(.catch #(core/setFailed (.-message %))))
;; else ignore
check-valid-task-promise)
(.catch #(core/setFailed (.-message %)))))
(recur (rest links))))
(js/console.log "No pull_request in payload"))))
8 changes: 2 additions & 6 deletions src/wrike_ist/wrike.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
(.then (fn [response]
(let [title (-> response
(get-in ["data" 0 "title"]))]
(.info js/console (str "Folder ID: " folder-id))
(.info js/console (str "Folder Title: " title))
(.info js/console (str "Folder ID: " folder-id " Title: " title))
(let [lowercase-folder-names (map clojure.string/lower-case folder-names)
parent-ids (-> response
(get-in ["data" 0 "parentIds"])
Expand All @@ -73,10 +72,7 @@
(.then
(find-task permalink)
(fn [{:strs [id parentIds superParentIds title]}]
(.info js/console (str "is-wrike-task-in-folder?: Task Name: " title))
(.info js/console (str "is-wrike-task-in-folder?: Task ID: " id))
(.info js/console (str "is-wrike-task-in-folder?: Parent IDs: " parentIds))
(.info js/console (str "is-wrike-task-in-folder?: Super Parent IDs: " superParentIds))
(.info js/console (str "is-wrike-task-in-folder?: Task Name: " title " id: " id " parentIds: " parentIds " superParentIds: " superParentIds))
(.info js/console (str "is-wrike-task-in-folder?: Folder names to match: " folder-names))
(let [all-parent-ids (concat parentIds superParentIds)
matching-folders-promises (for [parent-id all-parent-ids
Expand Down

0 comments on commit 3b5d3fa

Please sign in to comment.