mirror of
https://github.com/status-im/open-bounty.git
synced 2025-02-23 06:38:09 +00:00
Show tokens, ETH and USD value on UI
* make activity feed items and open bounties view show badges for ETH and tokems and total USD in item description * make top hunters work based on total USD value paid out in bounties * upgrade lein-cljsbuild
This commit is contained in:
parent
eb9b4d18b8
commit
584f742de9
@ -64,7 +64,7 @@
|
||||
|
||||
:plugins [[lein-cprop "1.0.1"]
|
||||
[migratus-lein "0.4.1"]
|
||||
[lein-cljsbuild "1.1.3"]
|
||||
[lein-cljsbuild "1.1.7"]
|
||||
[lein-auto "0.1.2"]
|
||||
[lein-less "1.7.5"]
|
||||
[lein-shell "0.5.0"]
|
||||
|
@ -251,8 +251,9 @@ SELECT
|
||||
i.comment_id AS comment_id,
|
||||
i.issue_number AS issue_number,
|
||||
i.issue_id AS issue_id,
|
||||
i.balance_eth AS balance,
|
||||
i.balance_eth AS balance_eth,
|
||||
i.tokens AS tokens,
|
||||
i.value_usd AS value_usd,
|
||||
u.login AS winner_login,
|
||||
u.address AS payout_address
|
||||
FROM issues i, pull_requests p, users u, repositories r
|
||||
@ -288,8 +289,9 @@ SELECT
|
||||
i.comment_id AS comment_id,
|
||||
i.issue_number AS issue_number,
|
||||
i.issue_id AS issue_id,
|
||||
i.balance_eth AS balance,
|
||||
i.balance_eth AS balance_eth,
|
||||
i.tokens AS tokens,
|
||||
i.value_usd AS value_usd,
|
||||
u.address AS payout_address,
|
||||
u.login AS payee_login,
|
||||
i.payout_hash AS payout_hash
|
||||
@ -355,8 +357,9 @@ SELECT
|
||||
i.issue_number AS issue_number,
|
||||
i.title AS issue_title,
|
||||
i.repo_id AS repo_id,
|
||||
i.balance_eth AS balance,
|
||||
i.balance_eth AS balance_eth,
|
||||
i.tokens AS tokens,
|
||||
i.value_usd AS value_usd,
|
||||
i.confirm_hash AS confirm_hash,
|
||||
i.payout_hash AS payout_hash,
|
||||
i.payout_receipt AS payout_receipt,
|
||||
@ -368,7 +371,7 @@ FROM issues i, repositories r
|
||||
WHERE
|
||||
r.repo_id = i.repo_id
|
||||
AND i.confirm_hash is null
|
||||
ORDER BY balance desc, updated desc; -- TODO: order by USD value first
|
||||
ORDER BY value_usd desc, updated desc;
|
||||
|
||||
|
||||
|
||||
@ -382,6 +385,7 @@ SELECT
|
||||
i.repo_id AS repo_id,
|
||||
i.balance_eth AS balance_eth,
|
||||
i.tokens AS tokens,
|
||||
i.value_usd AS value_usd,
|
||||
i.confirm_hash AS confirm_hash,
|
||||
i.payout_hash AS payout_hash,
|
||||
i.payout_receipt AS payout_receipt,
|
||||
@ -403,8 +407,9 @@ SELECT
|
||||
i.issue_number AS issue_number,
|
||||
i.title AS issue_title,
|
||||
i.repo_id AS repo_id,
|
||||
i.balance_eth AS balance,
|
||||
i.balance_eth AS balance_eth,
|
||||
i.tokens AS tokens,
|
||||
i.value_usd AS value_usd,
|
||||
i.confirm_hash AS confirm_hash,
|
||||
i.payout_hash AS payout_hash,
|
||||
i.payout_receipt AS payout_receipt,
|
||||
@ -438,8 +443,9 @@ SELECT
|
||||
i.comment_id AS comment_id,
|
||||
i.issue_number AS issue_number,
|
||||
i.issue_id AS issue_id,
|
||||
i.balance_eth AS balance,
|
||||
i.tokens AS tokens
|
||||
i.balance_eth AS balance_eth,
|
||||
i.tokens AS tokens,
|
||||
i.value_usd AS value_usd
|
||||
FROM issues i, repositories r
|
||||
WHERE r.repo_id = i.repo_id
|
||||
AND contract_address IS NOT NULL
|
||||
@ -451,8 +457,9 @@ SELECT
|
||||
i.contract_address AS contract_address,
|
||||
i.issue_id AS issue_id,
|
||||
i.issue_number AS issue_number,
|
||||
i.balance_eth AS balance,
|
||||
i.balance_eth AS balance_eth,
|
||||
i.tokens AS tokens,
|
||||
i.value_usd AS value_usd,
|
||||
r.owner AS owner,
|
||||
r.repo AS repo
|
||||
FROM issues i, repositories r
|
||||
@ -464,7 +471,7 @@ AND r.repo = :repo;
|
||||
-- :name update-eth-balance :! :n
|
||||
-- :doc updates balance of a wallet attached to a given issue
|
||||
UPDATE issues
|
||||
SET balance_eth = :balance,
|
||||
SET balance_eth = :balance_eth,
|
||||
updated = timezone('utc'::text, now())
|
||||
WHERE contract_address = :contract_address;
|
||||
|
||||
@ -494,14 +501,14 @@ u.id AS user_id,
|
||||
u.login AS login,
|
||||
u.name AS user_name,
|
||||
u.avatar_url AS avatar_url,
|
||||
SUM(i.balance_eth) AS total_eth
|
||||
SUM(i.value_usd) AS total_usd
|
||||
FROM issues i, users u, pull_requests pr
|
||||
WHERE
|
||||
pr.commit_sha = i.commit_sha
|
||||
AND u.id = pr.user_id
|
||||
AND i.payout_receipt IS NOT NULL
|
||||
GROUP BY u.id
|
||||
ORDER BY total_eth DESC; -- TODO: this should work with value_usd
|
||||
ORDER BY total_usd DESC;
|
||||
|
||||
|
||||
-- :name bounties-activity :? :*
|
||||
@ -514,7 +521,9 @@ SELECT
|
||||
issue_number,
|
||||
user_name,
|
||||
user_avatar_url,
|
||||
balance,
|
||||
balance_eth,
|
||||
tokens,
|
||||
value_usd,
|
||||
updated
|
||||
FROM activity_feed_view
|
||||
ORDER BY updated DESC
|
||||
|
@ -65,10 +65,10 @@
|
||||
(db/list-failed-deployments con-db)))
|
||||
|
||||
(defn update-eth-balance
|
||||
[contract-address balance]
|
||||
[contract-address balance-eth]
|
||||
(jdbc/with-db-connection [con-db *db*]
|
||||
(db/update-eth-balance con-db {:contract_address contract-address
|
||||
:balance balance})))
|
||||
:balance_eth balance-eth})))
|
||||
|
||||
(defn update-token-balances
|
||||
[contract-address balances]
|
||||
|
@ -15,14 +15,14 @@
|
||||
(if-let [{address :contract_address
|
||||
repo :repo
|
||||
issue-id :issue_id
|
||||
balance :balance}
|
||||
balance-eth :balance_eth}
|
||||
(bounties/get-bounty owner
|
||||
repo
|
||||
(Integer/parseInt issue))]
|
||||
(do
|
||||
(log/debug "address:" address)
|
||||
(log/debug owner repo issue balance)
|
||||
(log/debug hash (github/github-comment-hash owner repo issue balance))
|
||||
(log/debug owner repo issue balance-eth)
|
||||
(log/debug hash (github/github-comment-hash owner repo issue balance-eth))
|
||||
(if address
|
||||
(if-let [{png-data :png_data}
|
||||
(comment-images/get-image-data
|
||||
|
@ -15,7 +15,8 @@
|
||||
[clojure.tools.logging :as log]
|
||||
[commiteth.eth.core :as eth]
|
||||
[commiteth.config :refer [env]]
|
||||
[commiteth.util.util :refer [decimal->str]]
|
||||
[commiteth.util.util :refer [usd-decimal->str
|
||||
eth-decimal->str]]
|
||||
[crypto.random :as random]
|
||||
[clojure.set :refer [rename-keys]]
|
||||
[clojure.string :as str]))
|
||||
@ -112,11 +113,11 @@
|
||||
(let [owner-bounties (bounties-db/owner-bounties (:id user))]
|
||||
(into {}
|
||||
(for [ob owner-bounties
|
||||
:let [b (update ob :balance decimal->str)]]
|
||||
:let [b (update ob :value_usd usd-decimal->str)]]
|
||||
[(:issue_id b)
|
||||
(conj b
|
||||
(let [claims (map
|
||||
#(update % :balance decimal->str)
|
||||
#(update % :value_usd usd-decimal->str)
|
||||
(bounties-db/bounty-claims (:issue_id b)))]
|
||||
{:claims claims}))]))))
|
||||
|
||||
@ -124,26 +125,40 @@
|
||||
(defn top-hunters []
|
||||
(let [renames {:user_name :display-name
|
||||
:avatar_url :avatar-url
|
||||
:total_eth :total-eth}]
|
||||
:total_usd :total-usd}]
|
||||
(map #(-> %
|
||||
(rename-keys renames)
|
||||
(update :total-eth decimal->str))
|
||||
(update :total-usd usd-decimal->str))
|
||||
(bounties-db/top-hunters))))
|
||||
|
||||
|
||||
(defn activity-feed []
|
||||
(let [renames {:user_name :display-name
|
||||
(defn prettify-bounty-items [bounty-items]
|
||||
(let [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}
|
||||
activity-items (bounties-db/bounty-activity)]
|
||||
:issue_number :issue-number
|
||||
:value_usd :value-usd
|
||||
:balance_eth :balance-eth}]
|
||||
(map #(-> %
|
||||
(rename-keys renames)
|
||||
(update :balance decimal->str))
|
||||
activity-items)))
|
||||
(update :value-usd usd-decimal->str)
|
||||
(update :balance-eth eth-decimal->str)
|
||||
(update :tokens (fn [tokens]
|
||||
(into {}
|
||||
(map (fn [[tla balance]]
|
||||
[tla (format "%.2f" balance)])
|
||||
tokens)))))
|
||||
bounty-items)))
|
||||
|
||||
(defn activity-feed []
|
||||
(prettify-bounty-items (bounties-db/bounty-activity)))
|
||||
|
||||
(defn open-bounties []
|
||||
(prettify-bounty-items (bounties-db/open-bounties)))
|
||||
|
||||
|
||||
|
||||
(defn current-user-token [user]
|
||||
@ -173,8 +188,7 @@
|
||||
(ok (activity-feed)))
|
||||
(GET "/open-bounties" []
|
||||
(log/debug "/open-bounties")
|
||||
(ok (map #(update % :balance decimal->str)
|
||||
(bounties-db/open-bounties))))
|
||||
(ok (open-bounties)))
|
||||
(GET "/usage-metrics" []
|
||||
:query-params [token :- String]
|
||||
:auth-rules status-team-member?
|
||||
|
@ -7,7 +7,7 @@
|
||||
[commiteth.db.bounties :as db-bounties]
|
||||
[commiteth.bounties :as bounties]
|
||||
[commiteth.util.crypto-fiat-value :as fiat-util]
|
||||
[commiteth.util.util :refer [decimal->str]]
|
||||
[commiteth.util.util :refer [eth-decimal->str]]
|
||||
[clojure.tools.logging :as log]
|
||||
[mount.core :as mount]
|
||||
[clj-time.core :as t]
|
||||
@ -29,23 +29,23 @@
|
||||
repo :repo
|
||||
comment-id :comment_id
|
||||
issue-number :issue_number} issue
|
||||
balance-str (eth/get-balance-eth contract-address 6)
|
||||
balance (read-string balance-str)]
|
||||
balance-eth-str (eth/get-balance-eth contract-address 6)
|
||||
balance-eth (read-string balance-eth-str)]
|
||||
(bounties/update-bounty-comment-image issue-id
|
||||
owner
|
||||
repo
|
||||
issue-number
|
||||
contract-address
|
||||
balance
|
||||
balance-str
|
||||
balance-eth
|
||||
balance-eth-str
|
||||
{})
|
||||
(github/update-comment owner
|
||||
repo
|
||||
comment-id
|
||||
issue-number
|
||||
contract-address
|
||||
balance
|
||||
balance-str
|
||||
balance-eth
|
||||
balance-eth-str
|
||||
{}))))))
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@
|
||||
owner :owner
|
||||
comment-id :comment_id
|
||||
issue-number :issue_number
|
||||
balance :balance
|
||||
balance-eth :balance_eth
|
||||
tokens :tokens
|
||||
winner-login :winner_login} (db-bounties/pending-bounties)
|
||||
:let [value (eth/get-balance-hex contract-address)]]
|
||||
@ -99,7 +99,7 @@
|
||||
repo
|
||||
comment-id
|
||||
contract-address
|
||||
(decimal->str balance)
|
||||
(eth-decimal->str balance-eth)
|
||||
tokens
|
||||
winner-login)))))
|
||||
|
||||
@ -124,7 +124,7 @@
|
||||
owner :owner
|
||||
comment-id :comment_id
|
||||
issue-number :issue_number
|
||||
balance :balance
|
||||
balance-eth :balance_eth
|
||||
tokens :tokens
|
||||
payee-login :payee_login} (db-bounties/confirmed-payouts)]
|
||||
(log/debug "confirmed payout:" payout-hash)
|
||||
@ -135,7 +135,7 @@
|
||||
repo
|
||||
comment-id
|
||||
contract-address
|
||||
(decimal->str balance)
|
||||
(eth-decimal->str balance-eth)
|
||||
tokens
|
||||
payee-login))))
|
||||
|
||||
@ -205,7 +205,7 @@
|
||||
repo :repo
|
||||
comment-id :comment_id
|
||||
issue-id :issue_id
|
||||
db-balance-eth :balance
|
||||
db-balance-eth :balance_eth
|
||||
db-tokens :tokens
|
||||
issue-number :issue_number} (db-bounties/open-bounty-contracts)]
|
||||
(when comment-id
|
||||
|
@ -61,12 +61,12 @@
|
||||
(let [{owner :owner
|
||||
repo :repo
|
||||
issue-id :issue_id
|
||||
balance :balance} (db-bounties/get-bounty owner repo issue-number)
|
||||
balance-eth :balance_eth} (db-bounties/get-bounty owner repo issue-number)
|
||||
hash (github/github-comment-hash
|
||||
owner
|
||||
repo
|
||||
issue-number
|
||||
balance)]
|
||||
balance-eth)]
|
||||
(with-open [w (io/output-stream filename)]
|
||||
(.write w (:png_data (db/get-image-data issue-id hash))))))
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
(ns commiteth.util.util)
|
||||
|
||||
|
||||
(defn decimal->str [n]
|
||||
(defn eth-decimal->str [n]
|
||||
(format "%.4f" n))
|
||||
|
||||
(defn usd-decimal->str [n]
|
||||
(format "%.2f" n))
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
(defn item-description [{:keys [display-name
|
||||
balance
|
||||
value-usd
|
||||
issue-title
|
||||
item-type
|
||||
repo-owner
|
||||
@ -17,19 +17,22 @@
|
||||
issue-title]]
|
||||
(case item-type
|
||||
"new-bounty" [:div "New bounty opened for issue " issue-link]
|
||||
"claim-payout" [:div "Received ETH " balance
|
||||
"claim-payout" [:div "Received USD " value-usd
|
||||
" for " issue-link]
|
||||
"open-claim" [:div "Submitted a claim for " issue-link]
|
||||
"balance-update" [:div issue-link " bounty increased to ETH " balance]
|
||||
"balance-update" [:div issue-link " bounty increased to USD " value-usd]
|
||||
"")))
|
||||
|
||||
|
||||
(defn activity-item [{:keys [avatar-url
|
||||
display-name
|
||||
updated
|
||||
balance
|
||||
value-usd
|
||||
balance-eth
|
||||
issue-title
|
||||
item-type] :as item}]
|
||||
item-type
|
||||
tokens] :as item}]
|
||||
(println item)
|
||||
[:div.item.activity-item
|
||||
[:div.ui.mini.circular.image
|
||||
[:img {:src avatar-url}]]
|
||||
@ -39,7 +42,9 @@
|
||||
[item-description item]]
|
||||
[:div.footer-row
|
||||
(when-not (= item-type "new-bounty")
|
||||
[:div.balance-badge (str "ETH " balance )])
|
||||
(for [[tla balance] (merge tokens {:ETH balance-eth})]
|
||||
[:div.balance-badge
|
||||
(str (subs (str tla) 1) " " balance)]))
|
||||
[:div.time (moment-timestamp updated)]]]])
|
||||
|
||||
|
||||
|
@ -5,14 +5,15 @@
|
||||
|
||||
|
||||
(defn bounty-item [bounty]
|
||||
(println bounty)
|
||||
(let [{avatar-url :repo_owner_avatar_url
|
||||
owner :repo_owner
|
||||
repo-name :repo_name
|
||||
issue-title :issue_title
|
||||
issue-number :issue_number
|
||||
updated :updated
|
||||
balance :balance} bounty
|
||||
tokens :tokens
|
||||
balance-eth :balance-eth
|
||||
value-usd :value_usd} bounty
|
||||
full-repo (str owner "/" repo-name)
|
||||
issue-link [:a
|
||||
{:href (issue-url owner repo-name issue-number)}
|
||||
@ -25,7 +26,9 @@
|
||||
[:div.description
|
||||
issue-link]
|
||||
[:div.footer-row
|
||||
[:div.balance-badge (str "ETH " balance )]
|
||||
(for [[tla balance] (merge tokens {:ETH balance-eth})]
|
||||
[:div.balance-badge
|
||||
(str (subs (str tla) 1) " " balance)])
|
||||
[:div.time (moment-timestamp updated)]]]]))
|
||||
|
||||
(defn bounties-list [open-bounties]
|
||||
|
@ -130,7 +130,7 @@
|
||||
[:img {:src (:avatar-url hunter)}]]
|
||||
[:div.content
|
||||
[:div.header (:display-name hunter)]
|
||||
[:div.description (str "ETH " (:total-eth hunter))]]])
|
||||
[:div.description (str "USD " (:total-usd hunter))]]])
|
||||
@top-hunters))))))
|
||||
|
||||
(defn page []
|
||||
|
Loading…
x
Reference in New Issue
Block a user