From 21da4fb3b4368414f1b4b6b42aeb6fe1769e5974 Mon Sep 17 00:00:00 2001 From: Martin Klepsch Date: Wed, 28 Feb 2018 12:01:48 +0100 Subject: [PATCH] split user-bounties function into two --- src/clj/commiteth/routes/services.clj | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/clj/commiteth/routes/services.clj b/src/clj/commiteth/routes/services.clj index 5057eb5..8bb70db 100644 --- a/src/clj/commiteth/routes/services.clj +++ b/src/clj/commiteth/routes/services.clj @@ -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