diff --git a/src/clj/commiteth/routes/services.clj b/src/clj/commiteth/routes/services.clj index e7b8f52..435b172 100644 --- a/src/clj/commiteth/routes/services.clj +++ b/src/clj/commiteth/routes/services.clj @@ -146,32 +146,40 @@ (defn prettify-bounty-items [bounty-items] - (let [format-float (fn [balance] - (try - (format "%.2f" (float balance)) - (catch Throwable ex - (log/error "Failed to convert token value:" balance) - "0.00"))) - renames {:user_name :display-name - :user_avatar_url :avatar-url - :issue_title :issue-title - :type :item-type - :repo_name :repo-name - :repo_owner :repo-owner - :issue_number :issue-number - :value_usd :value-usd - :claim_count :claim-count - :balance_eth :balance-eth - :user_has_address :user-has-address}] + (let [format-float (fn [bounty balance] + (try + (format "%.2f" (double balance)) + (catch Throwable ex + (log/error (str (:repo-owner bounty) + "/" + (:repo-name bounty) + "/" + (:issue-number bounty)) + "Failed to convert token value:" balance) + "0.00"))) + update-token-values (fn [bounty] + (->> bounty + :tokens + (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 + :type :item-type + :repo_name :repo-name + :repo_owner :repo-owner + :issue_number :issue-number + :value_usd :value-usd + :claim_count :claim-count + :balance_eth :balance-eth + :user_has_address :user-has-address}] (map #(-> % (rename-keys renames) (update :value-usd usd-decimal->str) (update :balance-eth eth-decimal->str) - (update :tokens (fn [tokens] - (into {} - (map (fn [[tla balance]] - [tla (format-float balance)]) - tokens))))) + update-token-values) bounty-items))) (defn activity-feed []