mirror of
https://github.com/status-im/open-bounty.git
synced 2025-02-02 20:53:55 +00:00
Never show closed github issues as open bounties
* do not show a bounty issue in open bounties listing or activity feed items in case it was closed (manually or via PR) Fixes: #95
This commit is contained in:
parent
640cf8abd6
commit
6522265f7d
118
resources/migrations/20170912180820-issue-open-state.up.sql
Normal file
118
resources/migrations/20170912180820-issue-open-state.up.sql
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
ALTER TABLE "public"."issues"
|
||||||
|
ADD COLUMN "is_open" boolean DEFAULT 'true';
|
||||||
|
|
||||||
|
|
||||||
|
DROP VIEW "public"."bounties_view" CASCADE;
|
||||||
|
|
||||||
|
CREATE VIEW "public"."bounties_view" AS
|
||||||
|
SELECT i.title AS issue_title,
|
||||||
|
i.issue_number,
|
||||||
|
r.repo AS repo_name,
|
||||||
|
r.owner AS repo_owner,
|
||||||
|
concat(r.owner, '/', r.repo)::character varying(128) AS user_name,
|
||||||
|
r.owner_avatar_url AS user_avatar_url,
|
||||||
|
i.payout_receipt,
|
||||||
|
i.balance_eth as balance_eth,
|
||||||
|
i.updated,
|
||||||
|
i.tokens,
|
||||||
|
i.value_usd,
|
||||||
|
i.is_open AS issue_open
|
||||||
|
FROM issues i,
|
||||||
|
repositories r
|
||||||
|
WHERE r.repo_id = i.repo_id
|
||||||
|
AND i.contract_address IS NOT NULL
|
||||||
|
AND i.comment_id IS NOT NULL
|
||||||
|
ORDER BY i.updated;
|
||||||
|
|
||||||
|
|
||||||
|
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,
|
||||||
|
COALESCE(u.name, u.login) AS user_name,
|
||||||
|
u.avatar_url AS user_avatar_url,
|
||||||
|
i.payout_receipt,
|
||||||
|
p.updated,
|
||||||
|
i.balance_eth as balance_eth,
|
||||||
|
i.tokens,
|
||||||
|
i.value_usd,
|
||||||
|
p.state AS pr_state,
|
||||||
|
i.is_open AS issue_open
|
||||||
|
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.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-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.updated
|
||||||
|
FROM claims_view
|
||||||
|
WHERE claims_view.pr_state = 1
|
||||||
|
AND claims_view.payout_receipt IS NOT NULL
|
||||||
|
UNION
|
||||||
|
SELECT 'new-bounty'::text AS type,
|
||||||
|
bounties_view.issue_title,
|
||||||
|
bounties_view.repo_name,
|
||||||
|
bounties_view.repo_owner,
|
||||||
|
bounties_view.issue_number,
|
||||||
|
bounties_view.user_name,
|
||||||
|
bounties_view.user_avatar_url,
|
||||||
|
bounties_view.balance_eth,
|
||||||
|
bounties_view.tokens,
|
||||||
|
bounties_view.value_usd,
|
||||||
|
bounties_view.updated
|
||||||
|
FROM bounties_view
|
||||||
|
WHERE bounties_view.value_usd = 0::numeric
|
||||||
|
AND bounties_view.payout_receipt IS NULL
|
||||||
|
AND bounties_view.issue_open is true
|
||||||
|
UNION
|
||||||
|
SELECT 'balance-update'::text AS type,
|
||||||
|
bounties_view.issue_title,
|
||||||
|
bounties_view.repo_name,
|
||||||
|
bounties_view.repo_owner,
|
||||||
|
bounties_view.issue_number,
|
||||||
|
bounties_view.user_name,
|
||||||
|
bounties_view.user_avatar_url,
|
||||||
|
bounties_view.balance_eth,
|
||||||
|
bounties_view.tokens,
|
||||||
|
bounties_view.value_usd,
|
||||||
|
bounties_view.updated
|
||||||
|
FROM bounties_view
|
||||||
|
WHERE bounties_view.value_usd > 0::numeric
|
||||||
|
AND bounties_view.payout_receipt IS NULL
|
||||||
|
AND bounties_view.issue_open is true
|
||||||
|
ORDER BY 11 DESC;
|
@ -350,6 +350,20 @@ value_usd_updated = timezone('utc'::text, now())
|
|||||||
WHERE contract_address = :contract_address;
|
WHERE contract_address = :contract_address;
|
||||||
|
|
||||||
|
|
||||||
|
-- :name update-issue-open :! :n
|
||||||
|
-- :doc updates issue's open status
|
||||||
|
UPDATE issues
|
||||||
|
SET is_open = :is_open
|
||||||
|
WHERE issue_id = :issue_id;
|
||||||
|
|
||||||
|
|
||||||
|
-- :name issue-exists :1
|
||||||
|
-- :doc updates issue's open status
|
||||||
|
SELECT exists(SELECT 1
|
||||||
|
FROM issues
|
||||||
|
WHERE issue_id = :issue_id);
|
||||||
|
|
||||||
|
|
||||||
-- :name open-bounties :? :*
|
-- :name open-bounties :? :*
|
||||||
-- :doc all bounty issues for given owner
|
-- :doc all bounty issues for given owner
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -81,3 +81,15 @@
|
|||||||
(jdbc/with-db-connection [con-db *db*]
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
(db/update-usd-value con-db {:contract_address contract-address
|
(db/update-usd-value con-db {:contract_address contract-address
|
||||||
:usd_value usd-value})))
|
:usd_value usd-value})))
|
||||||
|
|
||||||
|
(defn update-open-status
|
||||||
|
[issue-id is-open]
|
||||||
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
|
(db/update-issue-open con-db {:issue_id issue-id
|
||||||
|
:is_open is-open})))
|
||||||
|
|
||||||
|
(defn is-bounty-issue?
|
||||||
|
[issue-id]
|
||||||
|
(let [res (jdbc/with-db-connection [con-db *db*]
|
||||||
|
(db/issue-exists con-db {:issue_id issue-id}))]
|
||||||
|
res))
|
||||||
|
@ -50,11 +50,15 @@
|
|||||||
(bounties/add-bounty-for-issue repo-name repo-id issue)))
|
(bounties/add-bounty-for-issue repo-name repo-id issue)))
|
||||||
|
|
||||||
(defn handle-issue-closed
|
(defn handle-issue-closed
|
||||||
;; TODO: does not work in case the issue is closed on github web ui
|
|
||||||
[{{{owner :login} :owner repo :name} :repository
|
[{{{owner :login} :owner repo :name} :repository
|
||||||
{issue-id :id issue-number :number} :issue}]
|
{issue-id :id issue-number :number} :issue}]
|
||||||
(log/debug "handle-issue-closed" owner repo issue-number issue-id)
|
(log/debug "handle-issue-closed" owner repo issue-number issue-id)
|
||||||
(when-let [commit-sha (find-commit-sha owner repo issue-number ["referenced" "closed"])]
|
|
||||||
|
(when (issues/is-bounty-issue? issue-id)
|
||||||
|
(log/debug "Updating issue status to closed")
|
||||||
|
(issues/update-open-status issue-id false))
|
||||||
|
|
||||||
|
#_(when-let [commit-sha (find-commit-sha owner repo issue-number ["referenced" "closed"])]
|
||||||
(log/debug (format "Issue %s/%s/%s closed with commit %s"
|
(log/debug (format "Issue %s/%s/%s closed with commit %s"
|
||||||
owner repo issue-number commit-sha))
|
owner repo issue-number commit-sha))
|
||||||
(log/info "NOT considering event as bounty winner")
|
(log/info "NOT considering event as bounty winner")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user