split user-bounties function into two

This commit is contained in:
Martin Klepsch 2018-02-28 12:01:48 +01:00 committed by Tetiana Churikova
parent 35f9685fad
commit 21da4fb3b4
1 changed files with 14 additions and 10 deletions

View File

@ -61,18 +61,22 @@
github-repos))))
(defn ^:private enrich-owner-bounties [owner-bounty]
(let [state (bounties/bounty-state owner-bounty)
claims (map
#(update % :value_usd usd-decimal->str)
(bounties-db/bounty-claims (:issue_id owner-bounty)))]
(-> owner-bounty
(update :value_usd usd-decimal->str)
(assoc :claims claims)
(assoc :state state))))
(defn user-bounties [user]
(let [owner-bounties (bounties-db/owner-bounties (:id user))]
(into {}
(for [ob owner-bounties
:let [b (update ob :value_usd usd-decimal->str)]]
[(:issue_id b)
(conj b
(let [claims (map
#(update % :value_usd usd-decimal->str)
(bounties-db/bounty-claims (:issue_id b)))]
{:claims claims}))]))))
(->> owner-bounties
(map enrich-owner-bounties)
(map (juxt :issue_id identity))
(into {}))))
(defn top-hunters []
(let [renames {:user_name :display-name