mirror of
https://github.com/status-im/open-bounty.git
synced 2025-01-11 10:06:20 +00:00
Introduce maybe-add-bounty-for-issue to limit max added
This commit is contained in:
parent
6cdcf3bfa0
commit
ee096a6ceb
@ -89,6 +89,10 @@ SELECT i.title, i.issue_number, r.repo, r.owner
|
||||
FROM issues i, repositories r
|
||||
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;
|
||||
|
||||
-- :name update-repo-generic :! :n
|
||||
/* :require [clojure.string :as string]
|
||||
|
@ -17,6 +17,16 @@
|
||||
(let [labels (:labels issue)]
|
||||
(some #(= label-name (:name %)) labels)))
|
||||
|
||||
;; TODO: Change max-limit, also defined in two places
|
||||
(defn maybe-add-bounty-for-issue [repo repo-id issue]
|
||||
(let [res (issues/get-issues-count repo-id)
|
||||
{issues-count :count} res
|
||||
max-limit
|
||||
limit-reacted? (> issues-count max-limit)
|
||||
_ log/debug ("*** get-issues-count" repo-id res count limit-reached?)]
|
||||
(if limit-reached?
|
||||
(log/debug "Total issues for repo limit reached " repo issues-count)
|
||||
(add-bounty-for-issue repo repo-id issue))))
|
||||
|
||||
(defn add-bounty-for-issue [repo repo-id issue]
|
||||
(let [{issue-id :id
|
||||
@ -62,7 +72,7 @@
|
||||
(log/debug (str "adding bounties for" (count bounty-issues)
|
||||
" existing issues (total " (count bounty-issues) ")"))
|
||||
(doall
|
||||
(map (partial add-bounty-for-issue repo repo-id) max-bounties))))
|
||||
(map (partial maybe-add-bounty-for-issue repo repo-id) max-bounties))))
|
||||
|
||||
|
||||
(defn update-bounty-comment-image [issue-id owner repo issue-number contract-address eth-balance eth-balance-str tokens]
|
||||
|
@ -24,6 +24,11 @@
|
||||
(jdbc/with-db-connection [con-db *db*]
|
||||
(db/get-issue-titles con-db {})))
|
||||
|
||||
(defn get-issues-count
|
||||
[repo-id]
|
||||
(jdbc/with-db-connection [con-db *db*]
|
||||
(db/get-issues-count con-db {:repo_id repo-id})))
|
||||
|
||||
(defn update-issue-title
|
||||
[issue-id title]
|
||||
(jdbc/with-db-connection [con-db *db*]
|
||||
|
@ -47,7 +47,7 @@
|
||||
(let [{issue :issue} webhook-payload
|
||||
{repo-id :id
|
||||
repo-name :name} (:repository webhook-payload)]
|
||||
(bounties/add-bounty-for-issue repo-name repo-id issue)))
|
||||
(bounties/maybe-add-bounty-for-issue repo-name repo-id issue)))
|
||||
|
||||
(defn handle-issue-closed
|
||||
[{{{owner :login} :owner repo :name} :repository
|
||||
|
Loading…
x
Reference in New Issue
Block a user