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,23 +126,25 @@
:claims :tokens :contract_address])
;; Some bounties have been paid out manually, the payout hash
;; was set properly but winner_login was not
(if-let [merged-or-paid? (or (:winner_login bounty)
(:payout_hash bounty))]
(cond
(:payout_hash bounty) :paid
(nil? (:payout_address bounty)) :pending-contributor-address
;; `confirm_hash` is set by us as soon as a PR is merged and the
;; contributor address is known. Usually end users should not need
;; to be aware of this step.
(nil? (:confirm_hash bounty)) :pending-sob-confirmation
;; `payout_hash` is set when the bounty issuer signs the payout
(nil? (:payout_hash bounty)) :pending-maintainer-confirmation
:else :merged)
(cond ; not yet merged
(< 1 (count (:claims bounty))) :multiple-claims
(= 1 (count (:claims bounty))) :claimed
(seq (:tokens bounty)) :funded
(:contract_address bounty) :opened)))
(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
(:payout_hash bounty) :paid
(nil? (:payout_address bounty)) :pending-contributor-address
;; `confirm_hash` is set by us as soon as a PR is merged and the
;; contributor address is known. Usually end users should not need
;; to be aware of this step.
(nil? (:confirm_hash bounty)) :pending-sob-confirmation
;; `payout_hash` is set when the bounty issuer signs the payout
(nil? (:payout_hash bounty)) :pending-maintainer-confirmation
:else :merged)
(cond ; not yet merged
(< 1 (count (open-claims bounty))) :multiple-claims
(= 1 (count (open-claims bounty))) :claimed
(seq (:tokens bounty)) :funded
(: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))