only consider open PRs when determining if there are claims

This commit is contained in:
Martin Klepsch 2018-04-24 11:11:35 +02:00 committed by Tetiana Churikova
parent 3706954703
commit 069053e970
2 changed files with 23 additions and 17 deletions

View File

@ -6,6 +6,7 @@
[commiteth.eth.core :as eth]
[commiteth.github.core :as github]
[commiteth.eth.multisig-wallet :as multisig]
[commiteth.model.bounty :as bnt]
[commiteth.util.png-rendering :as png-rendering]
[clojure.tools.logging :as log]))
@ -125,6 +126,8 @@
:claims :tokens :contract_address])
;; Some bounties have been paid out manually, the payout hash
;; was set properly but winner_login was not
(let [open-claims (fn open-claims [bounty]
(filter bnt/open? (:claims bounty)))]
(if-let [merged-or-paid? (or (:winner_login bounty)
(:payout_hash bounty))]
(cond
@ -138,10 +141,10 @@
(nil? (:payout_hash bounty)) :pending-maintainer-confirmation
:else :merged)
(cond ; not yet merged
(< 1 (count (:claims bounty))) :multiple-claims
(= 1 (count (:claims bounty))) :claimed
(< 1 (count (open-claims bounty))) :multiple-claims
(= 1 (count (open-claims bounty))) :claimed
(seq (:tokens bounty)) :funded
(:contract_address bounty) :opened)))
(:contract_address bounty) :opened))))
(comment
(def user 97496)

View File

@ -10,6 +10,9 @@
;; via a protocol. Clojure records could also be serialized via transit making it easier
;; to communicate what datatypes are returned where.
(defn open? [claim]
(assert (find claim :pr_state))
(= 0 (:pr_state claim)))
(defn merged? [claim]
(assert (find claim :pr_state))