From bea4321ca4eea71de8483a4fb30f0531051ddd4a Mon Sep 17 00:00:00 2001 From: Ivan Grishaev Date: Wed, 27 Dec 2017 18:47:37 +0300 Subject: [PATCH] 193 migrations updated --- .../20171226182259-hide-user.down.sql | 37 +++++++++++++++++-- .../20171226182259-hide-user.up.sql | 37 +++++++++++++++++-- resources/sql/queries.sql | 1 + 3 files changed, 67 insertions(+), 8 deletions(-) diff --git a/resources/migrations/20171226182259-hide-user.down.sql b/resources/migrations/20171226182259-hide-user.down.sql index e11839c..3706d48 100644 --- a/resources/migrations/20171226182259-hide-user.down.sql +++ b/resources/migrations/20171226182259-hide-user.down.sql @@ -1,6 +1,35 @@ -begin; +BEGIN; -alter table users - drop column is_hidden; +ALTER TABLE users + DROP COLUMN is_hidden; -commit; +-- 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; + +COMMIT; diff --git a/resources/migrations/20171226182259-hide-user.up.sql b/resources/migrations/20171226182259-hide-user.up.sql index 96b7fc7..2977180 100644 --- a/resources/migrations/20171226182259-hide-user.up.sql +++ b/resources/migrations/20171226182259-hide-user.up.sql @@ -1,6 +1,35 @@ -begin; +BEGIN; -alter table users - add column is_hidden boolean not null default false; +ALTER TABLE users + ADD COLUMN is_hidden BOOLEAN NOT NULL DEFAULT FALSE; -commit; +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 -- added + ORDER BY p.updated; + +COMMIT; diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index e8a3115..9d9acf2 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -571,6 +571,7 @@ WHERE pr.commit_sha = i.commit_sha AND u.id = pr.user_id AND i.payout_receipt IS NOT NULL +AND NOT u.is_hidden GROUP BY u.id ORDER BY total_usd DESC LIMIT 5;