This repository has been archived by the owner on Apr 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
193 Hide myself from the top hunters and activity lists #199
Merged
Merged
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
264a83c
193 gitignore files added + readme updated
igrishaev 7dbd327
193 makefile added
igrishaev 460eab8
193 sql migrations added
igrishaev 287922d
193 cider plugin removed
igrishaev 58de6ae
193 ignoring dev config
igrishaev 0eba6fe
193 start-end pairs added
igrishaev e44639a
193 server handler added
igrishaev b77a231
193 ui widget added
igrishaev bea4321
193 migrations updated
igrishaev fea8d4f
193 style added
igrishaev 559f4f4
193 checkbox updated
igrishaev 78d8b28
193 transaction removed
igrishaev 085e8ef
193 rolled back
igrishaev 07bb457
193 user exists query added
igrishaev 50e3045
193 address + hidden routes mixed
igrishaev 8937816
193 query field updated
igrishaev 2b7dff9
193 UI updated
igrishaev 6107fec
193 gitignore fix
igrishaev fb95fe6
193 print removed
igrishaev c860db5
193 config.example deleted
igrishaev b162bba
193 config file restored
igrishaev a0073b2
Merge branch 'develop' of https://github.com/status-im/open-bounty in…
igrishaev a61885d
193 get rid of passing user-id
igrishaev 596e6c9
Merge branch 'develop' of https://github.com/status-im/open-bounty in…
igrishaev c66691c
193 review fixes
igrishaev 56d1425
193 sql fix
igrishaev 21c869a
193 blank line removed
igrishaev c2d6094
Merge branch 'develop' of https://github.com/status-im/open-bounty in…
igrishaev 4717a1a
193 review fixes
igrishaev 34c1645
Merge branch 'develop' of https://github.com/status-im/open-bounty in…
igrishaev 092713a
193 merge artifacts
igrishaev 9732b7c
193 h3 added
igrishaev 38ecb91
Merge branch 'develop' of https://github.com/status-im/open-bounty in…
igrishaev a8cdaa4
Merge branch 'develop' into 193-hide-myself
igrishaev 187b748
Merge branch 'develop' into 193-hide-myself
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
BEGIN; | ||
|
||
-- restore the previous version of the view | ||
CREATE OR REPLACE 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; | ||
|
||
ALTER TABLE users | ||
DROP COLUMN is_hidden_in_hunters; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE users | ||
ADD COLUMN is_hidden_in_hunters BOOLEAN NOT NULL DEFAULT FALSE; | ||
|
||
CREATE OR REPLACE 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 | ||
AND NOT u.is_hidden_in_hunters -- added | ||
ORDER BY p.updated; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
:migration-table-name "schema_migrations" | ||
:db db}] | ||
(migratus/migrate migratus-config) | ||
(conman/bind-connection db "sql/queries.sql") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. duplication line |
||
(conman/connect! {:jdbc-url db}) | ||
db)) | ||
|
||
|
@@ -85,3 +84,11 @@ | |
(sql-value [value] (to-pg-json value)) | ||
IPersistentVector | ||
(sql-value [value] (to-pg-json value))) | ||
|
||
(defmacro with-tx [& body] | ||
"Performs a set of queries in transaction." | ||
`(conman/with-transaction [*db*] | ||
~@body)) | ||
|
||
(defn update! [& args] | ||
(apply jdbc/update! *db* args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
[compojure.api.meta :refer [restructure-param]] | ||
[buddy.auth.accessrules :refer [restrict]] | ||
[buddy.auth :refer [authenticated?]] | ||
[commiteth.db.core :as db] | ||
[commiteth.db.users :as users] | ||
[commiteth.db.usage-metrics :as usage-metrics] | ||
[commiteth.db.repositories :as repositories] | ||
|
@@ -214,26 +215,35 @@ | |
(do | ||
(log/debug "/usage-metrics" user) | ||
(ok (usage-metrics/usage-metrics-by-day)))) | ||
|
||
(context "/user" [] | ||
|
||
(GET "/" {:keys [params]} | ||
:auth-rules authenticated? | ||
:current-user user | ||
(ok (handle-get-user user (:token params)))) | ||
(POST "/address" [] | ||
|
||
(POST "/" [] | ||
:auth-rules authenticated? | ||
:body-params [user-id :- Long, address :- String] | ||
:summary "Update user address" | ||
(if-not (eth/valid-address? address) | ||
(do | ||
(log/debug "POST /address: invalid input" address) | ||
{:status 400 | ||
:body (str "Invalid Ethereum address '" address "'")}) | ||
(let [result (users/update-user-address | ||
user-id | ||
address)] | ||
(if (= 1 result) | ||
(ok) | ||
(internal-server-error))))) | ||
:current-user user | ||
:body [body {:address s/Str | ||
:is_hidden_in_hunters s/Bool}] | ||
:summary "Updates user's fields." | ||
|
||
(let [user-id (:id user) | ||
{:keys [address]} body] | ||
|
||
(when-not (eth/valid-address? address) | ||
(log/debugf "POST /user: Wrong address %s" address) | ||
(bad-request! (format "Invalid Ethereum address: %s" address))) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why these blank lines? |
||
(db/with-tx | ||
(when-not (db/user-exists? {:id user-id}) | ||
(not-found! "No such a user.")) | ||
(db/update! :users body ["id = ?" user-id])) | ||
|
||
(ok))) | ||
|
||
(GET "/repositories" {:keys [params]} | ||
:auth-rules authenticated? | ||
:current-user user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,16 @@ | |
[reagent.crypt :as crypt] | ||
[cljs-web3.eth :as web3-eth])) | ||
|
||
|
||
(defn update-address-page [] | ||
(let [db (rf/subscribe [:db]) | ||
user (rf/subscribe [:user]) | ||
updating-address (rf/subscribe [:get-in [:updating-address]]) | ||
address (r/atom @(rf/subscribe [:get-in [:user :address]]))] | ||
updating-user (rf/subscribe [:get-in [:updating-user]]) | ||
address (r/atom @(rf/subscribe [:get-in [:user :address]])) | ||
hidden (r/atom @(rf/subscribe [:get-in [:user :is_hidden_in_hunters]]))] | ||
|
||
(fn [] | ||
(let [web3 (:web3 @db) | ||
web3-accounts (when web3 | ||
(web3-eth/accounts web3))] | ||
(println "web3-accounts" web3-accounts) | ||
[:div.ui.container.grid | ||
[:div.ui.form.sixteen.wide.column | ||
[:h3 "Update address"] | ||
|
@@ -33,12 +32,29 @@ | |
:auto-correct "off" | ||
:spell-check "false" | ||
:max-length 42}]])] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some blank lines here and below. |
||
[:h3 "Settings"] | ||
|
||
[:div | ||
[:input | ||
{:type :checkbox | ||
:disabled @updating-user | ||
:id :input-hidden | ||
:checked @hidden | ||
:on-change | ||
(fn [e] | ||
(let [value (-> e .-target .-checked)] | ||
(reset! hidden value)))}] | ||
|
||
[:label {:for :input-hidden} "Disguise myself from the top hunters and activity lists."]] | ||
|
||
[:button | ||
(merge {:on-click | ||
#(rf/dispatch [:save-user-address | ||
(:id @user) | ||
@address]) | ||
#(rf/dispatch [:save-user-fields {:address @address | ||
:is_hidden_in_hunters @hidden}]) | ||
:class (str "ui button small update-address-button" | ||
(when @updating-address | ||
(when @updating-user | ||
" busy loading"))}) | ||
"UPDATE"]]])))) | ||
"UPDATE"] | ||
|
||
]])))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and below, I had to redefine existing DB view to add non-hidden user clause.