From aebdf5985e407145971c72a9b1327fa612ae358f Mon Sep 17 00:00:00 2001 From: Martin Klepsch Date: Fri, 30 Mar 2018 11:34:16 +0200 Subject: [PATCH] move bounty renames into separate def --- src/clj/commiteth/routes/services.clj | 39 ++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/clj/commiteth/routes/services.clj b/src/clj/commiteth/routes/services.clj index 656c804..f078057 100644 --- a/src/clj/commiteth/routes/services.clj +++ b/src/clj/commiteth/routes/services.clj @@ -60,6 +60,22 @@ (map update-enabled repos)}) github-repos)))) +(def bounty-renames + {:user_name :display-name + :user_avatar_url :avatar-url + :issue_title :issue-title + :pr_title :pr-title + :pr_number :pr-number + :pr_id :pr-id + :type :item-type + :repo_name :repo-name + :repo_owner :repo-owner + :issue_number :issue-number + :issue_id :issue-id + :value_usd :value-usd + :claim_count :claim-count + :balance_eth :balance-eth + :user_has_address :user-has-address}) (defn ^:private enrich-owner-bounties [owner-bounty] (let [claims (map @@ -67,7 +83,9 @@ (bounties-db/bounty-claims (:issue_id owner-bounty))) with-claims (assoc owner-bounty :claims claims)] (-> with-claims - (update :value_usd usd-decimal->str) + (rename-keys bounty-renames) + (update :value-usd usd-decimal->str) + (update :balance-eth eth-decimal->str) (assoc :state (bounties/bounty-state with-claims))))) (defn user-bounties [user] @@ -105,24 +123,9 @@ (map (fn [[tla balance]] [tla (format-float bounty balance)])) (into {}) - (assoc bounty :tokens))) - renames {:user_name :display-name - :user_avatar_url :avatar-url - :issue_title :issue-title - :pr_title :pr-title - :pr_number :pr-number - :pr_id :pr-id - :type :item-type - :repo_name :repo-name - :repo_owner :repo-owner - :issue_number :issue-number - :issue_id :issue-id - :value_usd :value-usd - :claim_count :claim-count - :balance_eth :balance-eth - :user_has_address :user-has-address}] + (assoc bounty :tokens)))] (map #(-> % - (rename-keys renames) + (rename-keys bounty-renames) (update :value-usd usd-decimal->str) (update :balance-eth eth-decimal->str) update-token-values)