From abac3f5cdb50f288fa68664524b144e18d9bdbce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Thor=C3=A9n?= Date: Tue, 31 Oct 2017 14:50:27 -0500 Subject: [PATCH] Max limit back to 2; make issues count more restrictive --- resources/sql/queries.sql | 6 ++++-- src/clj/commiteth/bounties.clj | 13 ++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 6b82a69..47e2bdb 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -91,8 +91,10 @@ WHERE i.repo_id = r.repo_id; -- :name get-issues-count :? :1 SELECT COUNT(*) -FROM issues i, repositories r -WHERE i.repo_id = :repo_id; +FROM issues i +WHERE i.repo_id = :repo_id +AND i.confirm_hash is null +AND i.is_open = true; -- :name update-repo-generic :! :n /* :require [clojure.string :as string] diff --git a/src/clj/commiteth/bounties.clj b/src/clj/commiteth/bounties.clj index cf4fbc5..a240c5d 100644 --- a/src/clj/commiteth/bounties.clj +++ b/src/clj/commiteth/bounties.clj @@ -12,6 +12,10 @@ (def ^:const label-name "bounty") +;; TODO: Change max-limit, also defined in two places +;; TODO: Change max limit to 1000 after testing +(def max-issues-limit 2) + (defn has-bounty-label? [issue] (let [labels (:labels issue)] @@ -47,13 +51,10 @@ (issues/update-transaction-hash issue-id transaction-hash)))) (log/debug "Issue already exists in DB, ignoring")))) -;; TODO: Change max-limit, also defined in two places -;; Note this is limits for total issues, need to take subset of this/join somehow (defn maybe-add-bounty-for-issue [repo repo-id issue] (let [res (issues/get-issues-count repo-id) {count :count} res - max-limit 10000 - limit-reached? (> count max-limit) + limit-reached? (> count max-issues-limit) _ (log/debug "*** get-issues-count" repo-id res count limit-reached?)] (if limit-reached? (log/debug "Total issues for repo limit reached " repo count) @@ -62,15 +63,13 @@ ;; We have a max-limit to ensure people can't add more issues and ;; drain bot account until we have economic design in place -;; TODO(oskarth): Update max-limit to 100 (defn add-bounties-for-existing-issues [full-name] (let [{repo-id :repo_id owner :owner repo :repo} (repos/get-repo full-name) issues (github/get-issues owner repo) bounty-issues (filter has-bounty-label? issues) - limit 100 - max-bounties (take limit bounty-issues)] + max-bounties (take max-issues-limit bounty-issues)] (log/debug (str "adding bounties for" (count bounty-issues) " existing issues (total " (count bounty-issues) ")")) (doall