From ef4e1f411e860c8e16d04d42313b4da1e0f53eb5 Mon Sep 17 00:00:00 2001 From: Martin Klepsch Date: Wed, 21 Feb 2018 18:17:32 +0100 Subject: [PATCH] #300: add function which returns state of a given bounty --- resources/sql/queries.sql | 5 +++-- src/clj/commiteth/bounties.clj | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 27f5d68..4f866af 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -453,8 +453,9 @@ SELECT i.updated AS updated, i.winner_login AS winner_login, r.repo AS repo_name, - o.address AS owner_address -FROM issues i, users o, repositories r + o.address AS owner_address, + u.address AS payout_address +FROM users o, repositories r, issues i LEFT OUTER JOIN users u ON u.login = i.winner_login WHERE r.repo_id = i.repo_id AND r.user_id = o.id diff --git a/src/clj/commiteth/bounties.clj b/src/clj/commiteth/bounties.clj index d911e6c..3358015 100644 --- a/src/clj/commiteth/bounties.clj +++ b/src/clj/commiteth/bounties.clj @@ -105,3 +105,14 @@ (do (log/info "Updating changed title for issue" (:id gh-issue)) (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))