Include winner in /user-bounties data & show on manage payouts
* include user-id, login and name of bounty winner in /user-bounties data * show (paid to <github-username>) instead of (paid) on manage payouts view
This commit is contained in:
parent
eaa1aadc1a
commit
ec2ac80478
|
@ -128,16 +128,14 @@ INSERT INTO issues (repo_id, issue_id, issue_number, title)
|
||||||
-- :name update-commit-sha :<! :1
|
-- :name update-commit-sha :<! :1
|
||||||
-- :doc updates issue with commit_sha
|
-- :doc updates issue with commit_sha
|
||||||
UPDATE issues
|
UPDATE issues
|
||||||
SET commit_sha = :commit_sha,
|
SET commit_sha = :commit_sha
|
||||||
updated = timezone('utc'::text, now())
|
|
||||||
WHERE issue_id = :issue_id
|
WHERE issue_id = :issue_id
|
||||||
RETURNING repo_id, issue_id, issue_number, title, commit_sha, contract_address;
|
RETURNING repo_id, issue_id, issue_number, title, commit_sha, contract_address;
|
||||||
|
|
||||||
-- :name update-transaction-hash :! :n
|
-- :name update-transaction-hash :! :n
|
||||||
-- :doc updates transaction-hash for a given issue
|
-- :doc updates transaction-hash for a given issue
|
||||||
UPDATE issues
|
UPDATE issues
|
||||||
SET transaction_hash = :transaction_hash,
|
SET transaction_hash = :transaction_hash
|
||||||
updated = timezone('utc'::text, now())
|
|
||||||
WHERE issue_id = :issue_id;
|
WHERE issue_id = :issue_id;
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,6 +310,24 @@ AND u.id = p.user_id
|
||||||
AND i.payout_receipt IS NULL
|
AND i.payout_receipt IS NULL
|
||||||
AND i.payout_hash IS NOT NULL;
|
AND i.payout_hash IS NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
|
-- :name get-bounty-winner :? :*
|
||||||
|
-- :doc return user_id, login and name for a user that has won and
|
||||||
|
-- been paid given bounty issue
|
||||||
|
SELECT
|
||||||
|
u.address AS payout_address,
|
||||||
|
u.login AS payee_login,
|
||||||
|
u.id AS payee_user_id,
|
||||||
|
u.name AS payee_name
|
||||||
|
FROM issues i, users u, pull_requests p
|
||||||
|
WHERE
|
||||||
|
i.issue_id = :issue_id
|
||||||
|
AND p.issue_id = i.issue_id
|
||||||
|
AND p.repo_id = i.repo_id
|
||||||
|
AND u.id = p.user_id
|
||||||
|
AND i.payout_receipt IS NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
-- :name update-confirm-hash :! :n
|
-- :name update-confirm-hash :! :n
|
||||||
-- :doc updates issue with confirmation hash
|
-- :doc updates issue with confirmation hash
|
||||||
UPDATE issues
|
UPDATE issues
|
||||||
|
|
|
@ -71,6 +71,10 @@
|
||||||
(jdbc/with-db-connection [con-db *db*]
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
(db/get-bounty con-db {:owner owner :repo repo :issue_number issue-number})))
|
(db/get-bounty con-db {:owner owner :repo repo :issue_number issue-number})))
|
||||||
|
|
||||||
|
(defn get-bounty-winner
|
||||||
|
[issue-id]
|
||||||
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
|
(db/get-bounty-winner con-db {:issue_id issue-id})))
|
||||||
|
|
||||||
(defn open-bounty-contracts
|
(defn open-bounty-contracts
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -126,9 +126,10 @@
|
||||||
(let [owner-bounties (bounties-db/owner-bounties (:id user))]
|
(let [owner-bounties (bounties-db/owner-bounties (:id user))]
|
||||||
(into {}
|
(into {}
|
||||||
(for [ob owner-bounties
|
(for [ob owner-bounties
|
||||||
:let [b (update ob :value_usd usd-decimal->str)]]
|
:let [b (update ob :value_usd usd-decimal->str)
|
||||||
|
winner (first (bounties-db/get-bounty-winner (:issue_id b)))]]
|
||||||
[(:issue_id b)
|
[(:issue_id b)
|
||||||
(conj b
|
(conj (conj b {:winner winner})
|
||||||
(let [claims (map
|
(let [claims (map
|
||||||
#(update % :value_usd usd-decimal->str)
|
#(update % :value_usd usd-decimal->str)
|
||||||
(bounties-db/bounty-claims (:issue_id b)))]
|
(bounties-db/bounty-claims (:issue_id b)))]
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
user-name :user_name
|
user-name :user_name
|
||||||
avatar-url :user_avatar_url
|
avatar-url :user_avatar_url
|
||||||
issue-id :issue_id
|
issue-id :issue_id
|
||||||
issue-title :issue_title} claim
|
issue-title :issue_title
|
||||||
|
winner :winner} claim
|
||||||
merged? (= 1 (:pr_state claim))
|
merged? (= 1 (:pr_state claim))
|
||||||
paid? (not-empty (:payout_hash claim))
|
paid? (not-empty (:payout_hash claim))
|
||||||
|
winner-login (:payee_login winner)
|
||||||
bot-confirm-unmined? (empty? (:confirm_hash bounty))
|
bot-confirm-unmined? (empty? (:confirm_hash bounty))
|
||||||
confirming? (:confirming? bounty)
|
confirming? (:confirming? bounty)
|
||||||
updated (:updated bounty)]
|
updated (:updated bounty)]
|
||||||
|
@ -30,7 +32,7 @@
|
||||||
[:div.description "Submitted a claim for " [:a {:href (pr-url claim)}
|
[:div.description "Submitted a claim for " [:a {:href (pr-url claim)}
|
||||||
issue-title]]
|
issue-title]]
|
||||||
[:div.description (if paid?
|
[:div.description (if paid?
|
||||||
"(paid)"
|
(str "(paid to " winner-login ")")
|
||||||
(str "(" (if merged? "merged" "open") ")"))]
|
(str "(" (if merged? "merged" "open") ")"))]
|
||||||
[:div.time (moment-timestamp updated)]
|
[:div.time (moment-timestamp updated)]
|
||||||
[:button.ui.button
|
[:button.ui.button
|
||||||
|
|
Loading…
Reference in New Issue