display other helpful fields if pr title is missing

This commit is contained in:
Rob Culliton 2018-03-14 12:49:00 -04:00 committed by Tetiana Churikova
parent dbb672318b
commit 6724e2612a
15 changed files with 333 additions and 51 deletions

View File

@ -0,0 +1 @@
ALTER TABLE "public"."pull_requests" DROP COLUMN "title";

View File

@ -0,0 +1 @@
ALTER TABLE "public"."pull_requests" ADD COLUMN "title" character varying(256);

View File

@ -0,0 +1,78 @@
-- restore the previous version of the view
CREATE VIEW "public"."claims_view" AS SELECT i.title AS issue_title,
i.issue_number,
r.repo AS repo_name,
r.owner AS repo_owner,
COALESCE(u.name, u.login) AS user_name,
u.avatar_url AS user_avatar_url,
i.payout_receipt,
p.updated,
i.updated AS issue_updated,
i.balance_eth,
i.tokens,
i.value_usd,
p.state AS pr_state,
i.is_open AS issue_open,
(case when u.address IS NULL THEN false ELSE true END) AS user_has_address
FROM issues i,
users u,
repositories r,
pull_requests p
WHERE r.repo_id = i.repo_id
AND p.issue_id = i.issue_id
AND p.user_id = u.id
AND i.contract_address IS NOT NULL
AND i.comment_id IS NOT NULL
ORDER BY p.updated;
CREATE OR REPLACE VIEW "public"."activity_feed_view" AS
SELECT 'open-claim'::text AS type,
claims_view.issue_title,
claims_view.repo_name,
claims_view.repo_owner,
claims_view.issue_number,
claims_view.user_name,
claims_view.user_avatar_url,
claims_view.balance_eth,
claims_view.tokens,
claims_view.value_usd,
claims_view.user_has_address,
claims_view.updated
FROM claims_view
WHERE claims_view.pr_state = 0
AND claims_view.payout_receipt IS NULL
AND claims_view.issue_open IS TRUE
UNION
SELECT 'claim-pending'::text AS type,
claims_view.issue_title,
claims_view.repo_name,
claims_view.repo_owner,
claims_view.issue_number,
claims_view.user_name,
claims_view.user_avatar_url,
claims_view.balance_eth,
claims_view.tokens,
claims_view.value_usd,
claims_view.user_has_address,
claims_view.issue_updated AS updated
FROM claims_view
WHERE claims_view.pr_state = 1
AND claims_view.payout_receipt IS NULL
UNION
SELECT 'claim-payout'::text AS type,
claims_view.issue_title,
claims_view.repo_name,
claims_view.repo_owner,
claims_view.issue_number,
claims_view.user_name,
claims_view.user_avatar_url,
claims_view.balance_eth,
claims_view.tokens,
claims_view.value_usd,
claims_view.user_has_address,
claims_view.issue_updated AS updated
FROM claims_view
WHERE claims_view.pr_state = 1
AND claims_view.payout_receipt IS NOT NULL
ORDER BY 12 DESC;

View File

@ -0,0 +1,91 @@
DROP VIEW "public"."claims_view" CASCADE;
CREATE VIEW "public"."claims_view" AS SELECT i.title AS issue_title,
i.issue_number,
r.repo AS repo_name,
r.owner AS repo_owner,
p.title AS pr_title, -- added
p.pr_number AS pr_number, -- added
p.pr_id AS pr_id, -- added
COALESCE(u.name, u.login) AS user_name,
u.avatar_url AS user_avatar_url,
i.payout_receipt,
p.updated,
i.updated AS issue_updated,
i.balance_eth,
i.tokens,
i.value_usd,
p.state AS pr_state,
i.is_open AS issue_open,
(case when u.address IS NULL THEN false ELSE true END) AS user_has_address
FROM issues i,
users u,
repositories r,
pull_requests p
WHERE r.repo_id = i.repo_id
AND p.issue_id = i.issue_id
AND p.user_id = u.id
AND i.contract_address IS NOT NULL
AND i.comment_id IS NOT NULL
ORDER BY p.updated;
CREATE VIEW "public"."activity_feed_view" AS -- altered
SELECT 'open-claim'::text AS type,
claims_view.issue_title,
claims_view.repo_name,
claims_view.repo_owner,
claims_view.pr_title, -- added
claims_view.pr_number, -- added
claims_view.pr_id, -- added
claims_view.issue_number,
claims_view.user_name,
claims_view.user_avatar_url,
claims_view.balance_eth,
claims_view.tokens,
claims_view.value_usd,
claims_view.user_has_address,
claims_view.updated
FROM claims_view
WHERE claims_view.pr_state = 0
AND claims_view.payout_receipt IS NULL
AND claims_view.issue_open IS TRUE
UNION
SELECT 'claim-pending'::text AS type,
claims_view.issue_title,
claims_view.repo_name,
claims_view.repo_owner,
claims_view.pr_title, -- added
claims_view.pr_number, -- added
claims_view.pr_id, -- added
claims_view.issue_number,
claims_view.user_name,
claims_view.user_avatar_url,
claims_view.balance_eth,
claims_view.tokens,
claims_view.value_usd,
claims_view.user_has_address,
claims_view.issue_updated AS updated
FROM claims_view
WHERE claims_view.pr_state = 1
AND claims_view.payout_receipt IS NULL
UNION
SELECT 'claim-payout'::text AS type,
claims_view.issue_title,
claims_view.repo_name,
claims_view.repo_owner,
claims_view.pr_title, -- added
claims_view.pr_number, -- added
claims_view.pr_id, -- added
claims_view.issue_number,
claims_view.user_name,
claims_view.user_avatar_url,
claims_view.balance_eth,
claims_view.tokens,
claims_view.value_usd,
claims_view.user_has_address,
claims_view.issue_updated AS updated
FROM claims_view
WHERE claims_view.pr_state = 1
AND claims_view.payout_receipt IS NOT NULL
ORDER BY 12 DESC;

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

View File

@ -207,6 +207,7 @@ AND i.transaction_hash IS NOT NULL;
INSERT INTO pull_requests (pr_id, INSERT INTO pull_requests (pr_id,
repo_id, repo_id,
pr_number, pr_number,
title,
issue_number, issue_number,
issue_id, issue_id,
commit_sha, commit_sha,
@ -215,6 +216,7 @@ INSERT INTO pull_requests (pr_id,
VALUES(:pr_id, VALUES(:pr_id,
:repo_id, :repo_id,
:pr_number, :pr_number,
:title,
:issue_number, :issue_number,
:issue_id, :issue_id,
:commit_sha, :commit_sha,
@ -225,6 +227,7 @@ SET
state = :state, state = :state,
issue_number = :issue_number, issue_number = :issue_number,
issue_id = :issue_id, issue_id = :issue_id,
title = :title,
updated = timezone('utc'::text, now()), updated = timezone('utc'::text, now()),
commit_sha = :commit_sha; commit_sha = :commit_sha;
@ -592,6 +595,9 @@ SELECT
issue_title, issue_title,
repo_name, repo_name,
repo_owner, repo_owner,
pr_number,
pr_title,
pr_id,
issue_number, issue_number,
user_name, user_name,
user_avatar_url, user_avatar_url,

View File

@ -109,10 +109,14 @@
renames {:user_name :display-name renames {:user_name :display-name
:user_avatar_url :avatar-url :user_avatar_url :avatar-url
:issue_title :issue-title :issue_title :issue-title
:pr_title :pr-title
:pr_number :pr-number
:pr_id :pr-id
:type :item-type :type :item-type
:repo_name :repo-name :repo_name :repo-name
:repo_owner :repo-owner :repo_owner :repo-owner
:issue_number :issue-number :issue_number :issue-number
:issue_id :issue-id
:value_usd :value-usd :value_usd :value-usd
:claim_count :claim-count :claim_count :claim-count
:balance_eth :balance-eth :balance_eth :balance-eth

View File

@ -115,18 +115,18 @@
(defn handle-claim (defn handle-claim
[issue user-id login name avatar_url owner repo repo-id pr-id pr-number head-sha merged? event-type] [issue user-id login name avatar_url owner repo repo-id pr-id pr-number pr-title head-sha merged? event-type]
(users/create-user user-id login name nil avatar_url) (users/create-user user-id login name nil avatar_url)
(let [open-or-edit? (contains? #{:opened :edited} event-type) (let [open-or-edit? (contains? #{:opened :edited} event-type)
close? (= :closed event-type) close? (= :closed event-type)
pr-data {:repo_id repo-id pr-data {:repo_id repo-id
:pr_id pr-id :pr_id pr-id
:pr_number pr-number :pr_number pr-number
:title pr-title
:user_id user-id :user_id user-id
:issue_number (:issue_number issue) :issue_number (:issue_number issue)
:issue_id (:issue_id issue) :issue_id (:issue_id issue)
:state event-type}] :state event-type}]
;; TODO: in the opened case if the submitting user has no ;; TODO: in the opened case if the submitting user has no
;; Ethereum address stored, we could post a comment to the ;; Ethereum address stored, we could post a comment to the
;; Github PR explaining that payout is not possible if the PR is ;; Github PR explaining that payout is not possible if the PR is
@ -187,6 +187,7 @@
repo-id repo-id
pr-id pr-id
pr-number pr-number
pr-title
head-sha head-sha
merged? merged?
event-type)) event-type))

View File

@ -4,51 +4,95 @@
[commiteth.common :refer [human-time [commiteth.common :refer [human-time
display-data-page display-data-page
items-per-page items-per-page
issue-url]] issue-url
pull-request-url]]
[commiteth.handlers :as handlers] [commiteth.handlers :as handlers]
[commiteth.db :as db] [commiteth.db :as db]
[commiteth.ui-model :as ui-model] [commiteth.ui-model :as ui-model]
[commiteth.subscriptions :as subs] [commiteth.subscriptions :as subs]
[commiteth.util :as util])) [commiteth.util :as util]))
(defn display-bounty-claims [claims]
[:div.bounty-claims-container.pv3
(for [claim claims]
(let [{:keys [avatar-url
pr-title
pr-id
updated
repo-owner
repo-name
pr-number]} claim]
^{:key pr-id}
[:div.bounty-claims-row.open-bounty-item-content.flex
[:div.bounty-claims-icon.pl2
[:div.ui.tiny.circular.image
[:img {:src avatar-url}]]]
[:span.bounty-claims-text.pt2.pl2
[:a.fw5
{:href (pull-request-url repo-owner repo-name pr-number)}
(if pr-title
pr-title
(str "#" pr-number " by " repo-owner " in " repo-name))]
[:span.time.pl2 (human-time updated)]]]))])
(defn blue-arrow-box [image-src]
"generates the appropriate container for a blue arrow"
[:span.blue-arrow-box.pa1
[:img.blue-arrow-image.v-mid {:src image-src}]])
(defn bounty-item [bounty] (defn bounty-item [bounty]
(let [{avatar-url :repo_owner_avatar_url (let [open-bounty-claims (rf/subscribe [::subs/open-bounty-claims])]
owner :repo-owner (fn [bounty]
repo-name :repo-name (let [{avatar-url :repo_owner_avatar_url
issue-title :issue-title owner :repo-owner
issue-number :issue-number repo-name :repo-name
updated :updated issue-title :issue-title
tokens :tokens issue-number :issue-number
balance-eth :balance-eth issue-id :issue-id
value-usd :value-usd updated :updated
claim-count :claim-count} bounty tokens :tokens
full-repo (str owner "/" repo-name) balance-eth :balance-eth
repo-url (str "https://github.com/" full-repo) value-usd :value-usd
repo-link [:a {:href repo-url} full-repo] claim-count :claim-count
issue-link [:a claims :claims} bounty
{:href (issue-url owner repo-name issue-number)} full-repo (str owner "/" repo-name)
issue-title]] repo-url (str "https://github.com/" full-repo)
[:div.open-bounty-item repo-link [:a {:href repo-url} full-repo]
[:div.open-bounty-item-content issue-link [:a
[:div.header issue-link] {:href (issue-url owner repo-name issue-number)}
[:div.bounty-item-row issue-title]
[:div.time (human-time updated)] open-claims-click #(rf/dispatch [::handlers/open-bounty-claim issue-id])
[:span.bounty-repo-label repo-link]] close-claims-click #(rf/dispatch [::handlers/close-bounty-claim issue-id])
matches-current-issue? (some #{issue-id} @open-bounty-claims)]
[:div.footer-row [:div
[:div.balance-badge "ETH " balance-eth] [:div.open-bounty-item
(for [[tla balance] tokens] [:div.open-bounty-item-content
^{:key (random-uuid)} [:div.header issue-link]
[:div.balance-badge.token [:div.bounty-item-row
(str (subs (str tla) 1) " " balance)]) [:div.time (human-time updated)]
[:span.usd-value-label "Value "] [:span.usd-balance-label (str "$" value-usd)] [:span.bounty-repo-label repo-link]]
(when (> claim-count 0) [:div.footer-row
[:span.open-claims-label (str claim-count " open claim" [:div.balance-badge "ETH " balance-eth]
(when (> claim-count 1) "s"))])]] (for [[tla balance] tokens]
[:div.open-bounty-item-icon ^{:key (random-uuid)}
[:div.ui.tiny.circular.image [:div.balance-badge.token
[:img {:src avatar-url}]]]])) (str (subs (str tla) 1) " " balance)])
[:span.usd-value-label "Value "] [:span.usd-balance-label (str "$" value-usd)]
(when (> claim-count 0)
[:span.open-claims-label
{:on-click (if matches-current-issue?
#(close-claims-click)
#(open-claims-click))}
(str claim-count " open claim"
(when (> claim-count 1) "s"))
(if matches-current-issue?
[blue-arrow-box "blue-arrow-up.png"]
[blue-arrow-box "blue-arrow-down.png"])])]]
[:div.open-bounty-item-icon
[:div.ui.tiny.circular.image
[:img {:src avatar-url}]]]]
(when matches-current-issue?
[display-bounty-claims claims])]))))
(defn bounties-filter-tooltip-value-input-view [label tooltip-open? opts] (defn bounties-filter-tooltip-value-input-view [label tooltip-open? opts]
[:div.open-bounties-filter-element-tooltip-value-input-container [:div.open-bounties-filter-element-tooltip-value-input-container

View File

@ -48,6 +48,9 @@
(defn issue-url [owner repo number] (defn issue-url [owner repo number]
(str "https://github.com/" owner "/" repo "/issues/" number)) (str "https://github.com/" owner "/" repo "/issues/" number))
(defn pull-request-url [owner repo number]
(str "https://github.com/" owner "/" repo "/pull/" number))
(def items-per-page 15) (def items-per-page 15)
(defn draw-page-numbers [page-number page-count container-element] (defn draw-page-numbers [page-number page-count container-element]

View File

@ -4,7 +4,7 @@
(def default-db (def default-db
{:page :bounties {:page :bounties
:user nil :user nil
:user-profile-loaded? false :user-profile-loaded? false
:repos-loading? false :repos-loading? false
:repos {} :repos {}
:activity-feed-loading? false :activity-feed-loading? false
@ -18,6 +18,7 @@
::ui-model/bounty-filter-type|currency nil ::ui-model/bounty-filter-type|currency nil
::ui-model/bounty-filter-type|date nil ::ui-model/bounty-filter-type|date nil
::ui-model/bounty-filter-type|owner nil} ::ui-model/bounty-filter-type|owner nil}
::open-bounty-claims #{}
:owner-bounties {} :owner-bounties {}
:top-hunters [] :top-hunters []
:activity-feed []}) :activity-feed []})

View File

@ -484,6 +484,16 @@
(.removeEventListener js/window "click" close-dropdown) (.removeEventListener js/window "click" close-dropdown)
(assoc db :user-dropdown-open? false))) (assoc db :user-dropdown-open? false)))
(reg-event-db
::open-bounty-claim
(fn [db [_ opening-issue-id]]
(update db ::db/open-bounty-claims #(conj % opening-issue-id))))
(reg-event-db
::close-bounty-claim
(fn [db [_ closing-issue-id]]
(update db ::db/open-bounty-claims #(disj % closing-issue-id))))
(reg-event-db (reg-event-db
::set-open-bounties-sorting-type ::set-open-bounties-sorting-type
(fn [db [_ sorting-type]] (fn [db [_ sorting-type]]

View File

@ -53,17 +53,24 @@
:open-bounties-page :open-bounties-page
:<- [::filtered-and-sorted-open-bounties] :<- [::filtered-and-sorted-open-bounties]
:<- [:page-number] :<- [:page-number]
(fn [[open-bounties page-number] _] :<- [:activity-feed]
(fn [[open-bounties page-number activity-feed] _]
(let [total-count (count open-bounties) (let [total-count (count open-bounties)
start (* (dec page-number) items-per-page) start (* (dec page-number) items-per-page)
end (min total-count (+ items-per-page start)) end (min total-count (+ items-per-page start))
items (subvec open-bounties start end)] items (->> (subvec open-bounties start end)
{:items items (map (fn [bounty]
:item-count (count items) (let [matching-claims (filter
(fn [claim]
(= (:issue-number claim)
(:issue-number bounty)))
activity-feed)]
(assoc bounty :claims matching-claims)))))]
{:items items
:item-count (count items)
:total-count total-count :total-count total-count
:page-number page-number :page-number page-number
:page-count (Math/ceil (/ total-count items-per-page))}))) :page-count (Math/ceil (/ total-count items-per-page))})))
(reg-sub (reg-sub
:owner-bounties :owner-bounties
@ -146,6 +153,11 @@
(fn [db _] (fn [db _]
(:user-dropdown-open? db))) (:user-dropdown-open? db)))
(reg-sub
::open-bounty-claims
(fn [db _]
(::db/open-bounty-claims db)))
(reg-sub (reg-sub
::open-bounties-sorting-type ::open-bounties-sorting-type
(fn [db _] (fn [db _]

View File

@ -714,6 +714,17 @@ label[for="input-hidden"] {
padding: 4px; padding: 4px;
text-align: center; text-align: center;
} }
.blue-arrow-box {
width: 24px;
height: 24px;
}
.blue-arrow-image {
width: 13.5px;
height: 6px;
}
} }
.open-bounty-item:first-child { .open-bounty-item:first-child {
@ -748,8 +759,6 @@ label[for="input-hidden"] {
font-size: 15px; font-size: 15px;
} }
border-bottom: #eaecee 1px solid !important;
.open-bounty-item-content { .open-bounty-item-content {
width: 80%; width: 80%;
padding: .7em 0 1em; padding: .7em 0 1em;
@ -780,8 +789,28 @@ label[for="input-hidden"] {
flex-direction: row !important; flex-direction: row !important;
justify-content: space-between; justify-content: space-between;
width: 80%; width: 80%;
} }
.bounty-claims-row {
padding-top: 6px;
padding-bottom: 6px;
}
.bounty-claims-container {
background-color: #FBFBFB;
}
.bounty-claims-icon {
width: 40px;
}
.bounty-claims-text {
a {
text-decoration: none;
color: #42505c;
}
}
.bounty-repo-label a { .bounty-repo-label a {
margin: auto; margin: auto;
font-family: "PostGrotesk-Book"; font-family: "PostGrotesk-Book";
@ -804,6 +833,7 @@ label[for="input-hidden"] {
padding-left: 15px; padding-left: 15px;
font-size: 15px; font-size: 15px;
color: #57a7ed; color: #57a7ed;
cursor: pointer;
} }
.activity-item-container { .activity-item-container {