Display issues list
This commit is contained in:
parent
4a5196987b
commit
7f6cb564a0
|
@ -16,11 +16,6 @@ html, body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-settings {
|
.profile-settings {
|
||||||
padding-top: 20px;
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
padding-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
button {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
|
@ -42,3 +37,8 @@ html, body {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
padding-top: 40px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
|
@ -78,11 +78,12 @@ WHERE repo_id = :repo_id;
|
||||||
|
|
||||||
-- :name create-issue! :! :n
|
-- :name create-issue! :! :n
|
||||||
-- :doc creates issue
|
-- :doc creates issue
|
||||||
INSERT INTO issues (repo_id, issue_id, issue_number, address)
|
INSERT INTO issues (repo_id, issue_id, issue_number, title, address)
|
||||||
SELECT
|
SELECT
|
||||||
:repo_id,
|
:repo_id,
|
||||||
:issue_id,
|
:issue_id,
|
||||||
:issue_number,
|
:issue_number,
|
||||||
|
:title,
|
||||||
:address
|
:address
|
||||||
WHERE NOT exists(SELECT 1
|
WHERE NOT exists(SELECT 1
|
||||||
FROM issues
|
FROM issues
|
||||||
|
@ -93,16 +94,17 @@ INSERT INTO issues (repo_id, issue_id, issue_number, address)
|
||||||
UPDATE issues
|
UPDATE issues
|
||||||
SET commit_id = :commit_id
|
SET commit_id = :commit_id
|
||||||
WHERE issue_id = :issue_id
|
WHERE issue_id = :issue_id
|
||||||
RETURNING repo_id, issue_id, issue_number, address, commit_id;
|
RETURNING repo_id, issue_id, issue_number, title, address, commit_id;
|
||||||
|
|
||||||
-- Pull Requests -------------------------------------------------------------------
|
-- Pull Requests -------------------------------------------------------------------
|
||||||
|
|
||||||
-- :name create-pull-request! :! :n
|
-- :name create-pull-request! :! :n
|
||||||
-- :doc creates pull request
|
-- :doc creates pull request
|
||||||
INSERT INTO pull_requests (repo_id, pr_id, user_id, parents)
|
INSERT INTO pull_requests (repo_id, pr_id, pr_number, user_id, parents)
|
||||||
SELECT
|
SELECT
|
||||||
:repo_id,
|
:repo_id,
|
||||||
:pr_id,
|
:pr_id,
|
||||||
|
:pr_number,
|
||||||
:user_id,
|
:user_id,
|
||||||
:parents
|
:parents
|
||||||
WHERE NOT exists(SELECT 1
|
WHERE NOT exists(SELECT 1
|
||||||
|
@ -115,12 +117,17 @@ INSERT INTO pull_requests (repo_id, pr_id, user_id, parents)
|
||||||
-- :doc lists fixed issues
|
-- :doc lists fixed issues
|
||||||
SELECT
|
SELECT
|
||||||
i.address AS issue_address,
|
i.address AS issue_address,
|
||||||
|
i.issue_id AS issue_id,
|
||||||
|
i.issue_number AS issue_number,
|
||||||
|
i.title AS issue_title,
|
||||||
i.repo_id AS repo_id,
|
i.repo_id AS repo_id,
|
||||||
p.pr_id AS pr_id,
|
p.pr_id AS pr_id,
|
||||||
p.user_id AS user_id,
|
p.user_id AS user_id,
|
||||||
|
p.pr_number AS pr_number,
|
||||||
u.address AS payout_address,
|
u.address AS payout_address,
|
||||||
u.login AS user_login,
|
u.login AS user_login,
|
||||||
u.name AS user_name,
|
u.name AS user_name,
|
||||||
|
r.login AS owner_name,
|
||||||
r.repo AS repo_name
|
r.repo AS repo_name
|
||||||
FROM issues i
|
FROM issues i
|
||||||
INNER JOIN pull_requests p
|
INNER JOIN pull_requests p
|
||||||
|
@ -131,3 +138,19 @@ FROM issues i
|
||||||
INNER JOIN repositories r
|
INNER JOIN repositories r
|
||||||
ON r.repo_id = i.repo_id
|
ON r.repo_id = i.repo_id
|
||||||
WHERE r.user_id = :owner_id;
|
WHERE r.user_id = :owner_id;
|
||||||
|
|
||||||
|
-- :name issues-list :? :*
|
||||||
|
-- :doc lists all issues
|
||||||
|
SELECT
|
||||||
|
i.address AS issue_address,
|
||||||
|
i.issue_id AS issue_id,
|
||||||
|
i.issue_number AS issue_number,
|
||||||
|
i.title AS issue_title,
|
||||||
|
i.repo_id AS repo_id,
|
||||||
|
r.login AS owner_name,
|
||||||
|
r.repo AS repo_name
|
||||||
|
FROM issues i
|
||||||
|
INNER JOIN repositories r
|
||||||
|
ON r.repo_id = i.repo_id
|
||||||
|
WHERE r.user_id = :owner_id
|
||||||
|
AND i.commit_id IS NULL;
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
(ns commiteth.db.bounties
|
||||||
|
(:require [commiteth.db.core :refer [*db*] :as db]
|
||||||
|
[clojure.java.jdbc :as jdbc]
|
||||||
|
[clojure.set :refer [rename-keys]]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn list-fixed-issues
|
||||||
|
[owner-id]
|
||||||
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
|
(db/bounties-list con-db {:owner_id owner-id})))
|
||||||
|
|
||||||
|
(defn list-not-fixed-issues
|
||||||
|
[owner-id]
|
||||||
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
|
(db/issues-list con-db {:owner_id owner-id})))
|
|
@ -5,11 +5,12 @@
|
||||||
|
|
||||||
(defn create
|
(defn create
|
||||||
"Creates issue"
|
"Creates issue"
|
||||||
[repo-id issue-id issue-number address]
|
[repo-id issue-id issue-number issue-title address]
|
||||||
(jdbc/with-db-connection [con-db *db*]
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
(db/create-issue! con-db {:repo_id repo-id
|
(db/create-issue! con-db {:repo_id repo-id
|
||||||
:issue_id issue-id
|
:issue_id issue-id
|
||||||
:issue_number issue-number
|
:issue_number issue-number
|
||||||
|
:title issue-title
|
||||||
:address address})))
|
:address address})))
|
||||||
|
|
||||||
(defn close
|
(defn close
|
||||||
|
|
|
@ -91,9 +91,9 @@
|
||||||
(repos/delete-hook user repo hook-id (auth-params token)))
|
(repos/delete-hook user repo hook-id (auth-params token)))
|
||||||
|
|
||||||
(defn post-comment
|
(defn post-comment
|
||||||
[user repo issue-id]
|
[user repo issue-id issue-address]
|
||||||
(issues/create-comment user repo issue-id
|
(issues/create-comment user repo issue-id
|
||||||
"a comment with an image link to the web service" (self-auth-params)))
|
(str "a comment with an image link to the web service. Issue address is " issue-address) (self-auth-params)))
|
||||||
|
|
||||||
(defn get-commit
|
(defn get-commit
|
||||||
[user repo commit-id]
|
[user repo commit-id]
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
[buddy.auth :refer [authenticated?]]
|
[buddy.auth :refer [authenticated?]]
|
||||||
[commiteth.db.users :as users]
|
[commiteth.db.users :as users]
|
||||||
[commiteth.db.repositories :as repositories]
|
[commiteth.db.repositories :as repositories]
|
||||||
|
[commiteth.db.bounties :as bounties]
|
||||||
[commiteth.github.core :as github]))
|
[commiteth.github.core :as github]))
|
||||||
|
|
||||||
(defn access-error [_ _]
|
(defn access-error [_ _]
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:body-params [user-id :- String, address :- String]
|
:body-params [user-id :- String, address :- String]
|
||||||
:summary "Update user address"
|
:summary "Update user address"
|
||||||
(let [result (users/update-user-address user-id address)]
|
(let [result (users/update-user-address (Integer/parseInt user-id) address)]
|
||||||
(if (= 1 result)
|
(if (= 1 result)
|
||||||
(ok)
|
(ok)
|
||||||
(internal-server-error))))
|
(internal-server-error))))
|
||||||
|
@ -52,6 +53,14 @@
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:current-user user
|
:current-user user
|
||||||
(ok (repositories/get-enabled (:id user))))
|
(ok (repositories/get-enabled (:id user))))
|
||||||
|
(GET "/bounties" []
|
||||||
|
:auth-rules authenticated?
|
||||||
|
:current-user user
|
||||||
|
(ok (bounties/list-fixed-issues (:id user))))
|
||||||
|
(GET "/issues" []
|
||||||
|
:auth-rules authenticated?
|
||||||
|
:current-user user
|
||||||
|
(ok (bounties/list-not-fixed-issues (:id user))))
|
||||||
(POST "/repository/toggle" {:keys [params]}
|
(POST "/repository/toggle" {:keys [params]}
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:current-user user
|
:current-user user
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
login :login
|
login :login
|
||||||
name :name} :user
|
name :name} :user
|
||||||
id :id
|
id :id
|
||||||
|
pr-number :number
|
||||||
merge-commit-sha :merge_commit_sha} :pull_request}]
|
merge-commit-sha :merge_commit_sha} :pull_request}]
|
||||||
(future
|
(future
|
||||||
(->>
|
(->>
|
||||||
|
@ -44,6 +45,7 @@
|
||||||
(hash-map :parents)
|
(hash-map :parents)
|
||||||
(merge {:repo_id repo-id
|
(merge {:repo_id repo-id
|
||||||
:pr_id id
|
:pr_id id
|
||||||
|
:pr_number pr-number
|
||||||
:user_id user-id})
|
:user_id user-id})
|
||||||
(pull-requests/create))
|
(pull-requests/create))
|
||||||
(users/create-user user-id login name nil nil)))
|
(users/create-user user-id login name nil nil)))
|
||||||
|
@ -66,15 +68,17 @@
|
||||||
[issue]
|
[issue]
|
||||||
(when-let [action (:action issue)]
|
(when-let [action (:action issue)]
|
||||||
(when (labeled-as-bounty? action issue)
|
(when (labeled-as-bounty? action issue)
|
||||||
(github/post-comment
|
(let [repository (:repository issue)
|
||||||
(get-in issue [:repository :owner :login])
|
{repo-id :id
|
||||||
(get-in issue [:repository :name])
|
{owner-login :login} :owner
|
||||||
(get-in issue [:issue :number]))
|
repo-name :name} repository
|
||||||
(let [repo-id (get-in issue [:repository :id])
|
|
||||||
issue (:issue issue)
|
issue (:issue issue)
|
||||||
issue-id (:id issue)
|
{issue-id :id
|
||||||
issue-number (:number issue)]
|
issue-number :number
|
||||||
(issues/create repo-id issue-id issue-number (gen-address))))
|
issue-title :title} issue
|
||||||
|
issue-address (gen-address)]
|
||||||
|
(github/post-comment owner-login repo-name issue-number issue-address)
|
||||||
|
(issues/create repo-id issue-id issue-number issue-title issue-address)))
|
||||||
(when (and
|
(when (and
|
||||||
(= "closed" action)
|
(= "closed" action)
|
||||||
(has-bounty-label? issue))
|
(has-bounty-label? issue))
|
||||||
|
|
|
@ -5,4 +5,6 @@
|
||||||
:user nil
|
:user nil
|
||||||
:user-profile nil
|
:user-profile nil
|
||||||
:repos []
|
:repos []
|
||||||
:enabled-repos {}})
|
:enabled-repos {}
|
||||||
|
:bounties []
|
||||||
|
:issues []})
|
||||||
|
|
|
@ -32,7 +32,35 @@
|
||||||
{:db (assoc db :user user)
|
{:db (assoc db :user user)
|
||||||
:dispatch-n [[:load-user-profile]
|
:dispatch-n [[:load-user-profile]
|
||||||
[:load-user-repos]
|
[:load-user-repos]
|
||||||
[:load-enabled-repos]]}))
|
[:load-enabled-repos]
|
||||||
|
[:load-bounties]
|
||||||
|
[:load-issues]]}))
|
||||||
|
|
||||||
|
(reg-event-fx
|
||||||
|
:load-bounties
|
||||||
|
(fn [{:keys [db]} [_]]
|
||||||
|
{:db db
|
||||||
|
:http {:method GET
|
||||||
|
:url "/api/bounties"
|
||||||
|
:on-success #(dispatch [:set-bounties %])}}))
|
||||||
|
|
||||||
|
(reg-event-db
|
||||||
|
:set-bounties
|
||||||
|
(fn [db [_ bounties]]
|
||||||
|
(assoc db :bounties bounties)))
|
||||||
|
|
||||||
|
(reg-event-fx
|
||||||
|
:load-issues
|
||||||
|
(fn [{:keys [db]} [_]]
|
||||||
|
{:db db
|
||||||
|
:http {:method GET
|
||||||
|
:url "/api/issues"
|
||||||
|
:on-success #(dispatch [:set-issues %])}}))
|
||||||
|
|
||||||
|
(reg-event-db
|
||||||
|
:set-issues
|
||||||
|
(fn [db [_ issues]]
|
||||||
|
(assoc db :issues issues)))
|
||||||
|
|
||||||
(reg-event-fx
|
(reg-event-fx
|
||||||
:load-user-profile
|
:load-user-profile
|
||||||
|
@ -89,4 +117,4 @@
|
||||||
:http {:method POST
|
:http {:method POST
|
||||||
:url "/api/user/address"
|
:url "/api/user/address"
|
||||||
:on-success #(println %)
|
:on-success #(println %)
|
||||||
:params {:user_id user-id :address address}}}))
|
:params {:user-id user-id :address address}}}))
|
||||||
|
|
|
@ -1,7 +1,73 @@
|
||||||
(ns commiteth.home.page
|
(ns commiteth.home.page
|
||||||
(:require [re-frame.core :as rf]))
|
(:require [re-frame.core :as rf]))
|
||||||
|
|
||||||
|
(def github-url "https://github.com/")
|
||||||
|
|
||||||
|
(defn issue-url
|
||||||
|
[user repo issue-number]
|
||||||
|
(str github-url user "/" repo "/issues/" issue-number))
|
||||||
|
|
||||||
|
(defn pull-url
|
||||||
|
[user repo pull-number]
|
||||||
|
(str github-url user "/" repo "/pull/" pull-number))
|
||||||
|
|
||||||
|
(defn user-url
|
||||||
|
[user]
|
||||||
|
(str github-url user))
|
||||||
|
|
||||||
|
(defn get-amount
|
||||||
|
[address]
|
||||||
|
(.-length address))
|
||||||
|
|
||||||
|
(defn bounty-row [{issue-id :issue_id
|
||||||
|
issue-number :issue_number
|
||||||
|
pr-number :pr_number
|
||||||
|
user :user_login
|
||||||
|
owner :owner_name
|
||||||
|
repo :repo_name
|
||||||
|
issue-title :issue_title
|
||||||
|
address :payout_address
|
||||||
|
issue-address :issue_address}]
|
||||||
|
^{:key issue-id}
|
||||||
|
[:li.list-group-item
|
||||||
|
[:div
|
||||||
|
[:a {:href (issue-url owner repo issue-number)} issue-title]]
|
||||||
|
[:div
|
||||||
|
[:a {:href (pull-url owner repo pr-number)} "fixed"]
|
||||||
|
" by "
|
||||||
|
[:a {:href (user-url user)} user]]
|
||||||
|
[:div "Payout address: " address]
|
||||||
|
[:div "Amount: " (get-amount issue-address) " ETH"]])
|
||||||
|
|
||||||
|
(defn bounties-list []
|
||||||
|
(let [bounties (rf/subscribe [:bounties])]
|
||||||
|
(fn []
|
||||||
|
[:ul.list-group
|
||||||
|
(map bounty-row @bounties)])))
|
||||||
|
|
||||||
|
|
||||||
|
(defn issue-row [{issue-id :issue_id
|
||||||
|
issue-number :issue_number
|
||||||
|
owner :owner_name
|
||||||
|
repo :repo_name
|
||||||
|
issue-title :issue_title
|
||||||
|
issue-address :issue_address}]
|
||||||
|
^{:key issue-id}
|
||||||
|
[:li.list-group-item
|
||||||
|
[:div
|
||||||
|
[:a {:href (issue-url owner repo issue-number)} issue-title]]
|
||||||
|
[:div "Amount: " (get-amount issue-address) " ETH"]])
|
||||||
|
|
||||||
|
(defn issues-list []
|
||||||
|
(let [issues (rf/subscribe [:issues])]
|
||||||
|
(fn []
|
||||||
|
[:ul.list-group
|
||||||
|
(map issue-row @issues)])))
|
||||||
|
|
||||||
(defn home-page []
|
(defn home-page []
|
||||||
(fn []
|
(fn []
|
||||||
[:div
|
[:div
|
||||||
[:h4 "Hi"]]))
|
[:h3 "List of issues fixed by PRs awaiting to be signed "]
|
||||||
|
[bounties-list]
|
||||||
|
[:h3 "List of all issues"]
|
||||||
|
[issues-list]]))
|
||||||
|
|
|
@ -16,6 +16,16 @@
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(:repos db)))
|
(:repos db)))
|
||||||
|
|
||||||
|
(reg-sub
|
||||||
|
:bounties
|
||||||
|
(fn [db _]
|
||||||
|
(:bounties db)))
|
||||||
|
|
||||||
|
(reg-sub
|
||||||
|
:issues
|
||||||
|
(fn [db _]
|
||||||
|
(:issues db)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub
|
||||||
:get-in
|
:get-in
|
||||||
(fn [db [_ path]]
|
(fn [db [_ path]]
|
||||||
|
|
Loading…
Reference in New Issue