#300: better guard around nil properties

This commit is contained in:
Martin Klepsch 2018-02-21 18:36:21 +01:00 committed by Tetiana Churikova
parent ef4e1f411e
commit f654e0452f
1 changed files with 11 additions and 9 deletions

View File

@ -107,12 +107,14 @@
(issues/update-issue-title (:id gh-issue) (:title gh-issue)))))))
(defn bounty-state [bounty]
(cond
(:payout_hash bounty) :paid
(nil? (:confirm_hash bounty)) :pending-maintainer-confirmation
(nil? (:payout_address bounty)) :pending-contributor-address
(:winner_login bounty) :merged
(some-> (:claim_count bounty) (< 1)) :multiple_claims
(= 1 (:claim_count bounty)) :claimed
(seq (:tokens bounty)) :funded
(:contract_address bounty) :opened))
(if-let [merged? (:winner_login bounty)]
(cond
(nil? (:payout_address bounty)) :pending-contributor-address
(nil? (:confirm_hash bounty)) :pending-maintainer-confirmation
(:payout_hash bounty) :paid
:else :merged)
(cond ; not yet merged
(some-> (:claim_count bounty) (< 1)) :multiple_claims
(= 1 (:claim_count bounty)) :claimed
(seq (:tokens bounty)) :funded
(:contract_address bounty) :opened)))