Merge branch 'develop' into fix/nonce-increment

This commit is contained in:
Vitaliy Vlasov 2018-04-18 11:41:21 +03:00
commit 0105d809cc
No known key found for this signature in database
GPG Key ID: A7D57C347F2B2964
16 changed files with 343 additions and 57 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,95 @@
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
i.issue_id AS issue_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.issue_id, -- added
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.issue_id, -- added
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.issue_id, -- added
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,7 +595,11 @@ SELECT
issue_title, issue_title,
repo_name, repo_name,
repo_owner, repo_owner,
pr_number,
pr_title,
pr_id,
issue_number, issue_number,
issue_id,
user_name, user_name,
user_avatar_url, user_avatar_url,
balance_eth, balance_eth,

View File

@ -34,7 +34,7 @@
(defn update-repo-state (defn update-repo-state
[repo-id repo-state] [repo-id repo-state]
(jdbc/with-db-connection [con-db *db*] (jdbc/with-db-connection [con-db *db*]
(db/update-repo-name con-db {:repo_id repo-id (db/update-repo-state con-db {:repo_id repo-id
:repo_state repo-state}))) :repo_state repo-state})))
(defn get-repo (defn get-repo
"Get a repo from DB given it's full name (owner/repo-name)" "Get a repo from DB given it's full name (owner/repo-name)"

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,38 +4,73 @@
[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.ph4.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 [open-bounty-claims (rf/subscribe [::subs/open-bounty-claims])]
(fn [bounty]
(let [{avatar-url :repo_owner_avatar_url (let [{avatar-url :repo_owner_avatar_url
owner :repo-owner owner :repo-owner
repo-name :repo-name repo-name :repo-name
issue-title :issue-title issue-title :issue-title
issue-number :issue-number issue-number :issue-number
issue-id :issue-id
updated :updated updated :updated
tokens :tokens tokens :tokens
balance-eth :balance-eth balance-eth :balance-eth
value-usd :value-usd value-usd :value-usd
claim-count :claim-count} bounty claim-count :claim-count
claims :claims} bounty
full-repo (str owner "/" repo-name) full-repo (str owner "/" repo-name)
repo-url (str "https://github.com/" full-repo) repo-url (str "https://github.com/" full-repo)
repo-link [:a {:href repo-url} full-repo] repo-link [:a {:href repo-url} full-repo]
issue-link [:a issue-link [:a
{:href (issue-url owner repo-name issue-number)} {:href (issue-url owner repo-name issue-number)}
issue-title]] issue-title]
[:div.open-bounty-item open-claims-click #(rf/dispatch [::handlers/open-bounty-claim issue-id])
close-claims-click #(rf/dispatch [::handlers/close-bounty-claim issue-id])
matches-current-issue? (some #{issue-id} @open-bounty-claims)]
[:div
[:div.open-bounty-item.ph4
[:div.open-bounty-item-content [:div.open-bounty-item-content
[:div.header issue-link] [:div.header issue-link]
[:div.bounty-item-row [:div.bounty-item-row
[:div.time (human-time updated)] [:div.time (human-time updated)]
[:span.bounty-repo-label repo-link]] [:span.bounty-repo-label repo-link]]
[:div.footer-row [:div.footer-row
[:div.balance-badge "ETH " balance-eth] [:div.balance-badge "ETH " balance-eth]
(for [[tla balance] tokens] (for [[tla balance] tokens]
@ -44,11 +79,20 @@
(str (subs (str tla) 1) " " balance)]) (str (subs (str tla) 1) " " balance)])
[:span.usd-value-label "Value "] [:span.usd-balance-label (str "$" value-usd)] [:span.usd-value-label "Value "] [:span.usd-balance-label (str "$" value-usd)]
(when (> claim-count 0) (when (> claim-count 0)
[:span.open-claims-label (str claim-count " open claim" [:span.open-claims-label
(when (> claim-count 1) "s"))])]] {: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.open-bounty-item-icon
[:div.ui.tiny.circular.image [:div.ui.tiny.circular.image
[:img {:src avatar-url}]]]])) [: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
@ -210,7 +254,7 @@
[:div [:div
(let [left (inc (* (dec page-number) items-per-page)) (let [left (inc (* (dec page-number) items-per-page))
right (dec (+ left item-count))] right (dec (+ left item-count))]
[:div.item-counts-label-and-sorting-container [:div.item-counts-label-and-sorting-container.ph4
[:div.item-counts-label [:div.item-counts-label
[:span (str "Showing " left "-" right " of " total-count)]] [:span (str "Showing " left "-" right " of " total-count)]]
[bounties-sort-view]]) [bounties-sort-view]])
@ -227,7 +271,7 @@
[:div.ui.text.loader.view-loading-label "Loading"]]] [:div.ui.text.loader.view-loading-label "Loading"]]]
[:div.ui.container.open-bounties-container [:div.ui.container.open-bounties-container
{:ref #(reset! container-element %1)} {:ref #(reset! container-element %1)}
[:div.open-bounties-header "Bounties"] [:div.open-bounties-header.ph4.pt4 "Bounties"]
[:div.open-bounties-filter-and-sort [:div.open-bounties-filter-and-sort.ph4
[bounty-filters-view]] [bounty-filters-view]]
[bounties-list @bounty-page-data container-element]])))) [bounties-list @bounty-page-data container-element]]))))

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]
@ -132,7 +135,7 @@
:else :else
[:div [:div
[draw-items] [draw-items]
[:div.page-nav-container [:div.page-nav-container.ph4.pb4
[:div.page-direction-container [:div.page-direction-container
[draw-rect :backward] [draw-rect :backward]
[draw-rect :forward]] [draw-rect :forward]]

View File

@ -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,18 +53,25 @@
: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)
(map (fn [bounty]
(let [matching-claims (filter
(fn [claim]
(= (:issue-id claim)
(:issue-id bounty)))
activity-feed)]
(assoc bounty :claims matching-claims)))))]
{:items items {:items items
:item-count (count 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
(fn [db _] (fn [db _]
@ -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

@ -415,7 +415,6 @@ label[for="input-hidden"] {
background-color: #fff; background-color: #fff;
border-radius: 10px; border-radius: 10px;
transform: translateY(-45px); transform: translateY(-45px);
padding: 24px;
.open-bounties-header { .open-bounties-header {
font-family: "PostGrotesk-Medium"; font-family: "PostGrotesk-Medium";
font-size: 21px; font-size: 21px;
@ -714,6 +713,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 +758,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 +788,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 +832,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 {