From 99705264ea2adce3b9ab5b6a53764030b610777c Mon Sep 17 00:00:00 2001 From: kagel Date: Wed, 31 Aug 2016 04:49:26 +0300 Subject: [PATCH] Another bugfix --- resources/sql/queries.sql | 3 ++- src/clj/commiteth/routes/webhooks.clj | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 2f3897c..6b9c464 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -101,11 +101,12 @@ RETURNING repo_id, issue_id, issue_number, title, address, commit_id; -- :name create-pull-request! :! :n -- :doc creates pull request -INSERT INTO pull_requests (repo_id, pr_id, pr_number, user_id) +INSERT INTO pull_requests (repo_id, pr_id, pr_number, commit_id, user_id) SELECT :repo_id, :pr_id, :pr_number, + :commit_id, :user_id WHERE NOT exists(SELECT 1 FROM pull_requests diff --git a/src/clj/commiteth/routes/webhooks.clj b/src/clj/commiteth/routes/webhooks.clj index 208ad07..8fb27c2 100644 --- a/src/clj/commiteth/routes/webhooks.clj +++ b/src/clj/commiteth/routes/webhooks.clj @@ -11,14 +11,17 @@ (def label-name "bounty") (defn find-issue-event - [events type] - (first (filter #(= type (:event %)) events))) + [events type owner] + (first (filter #(and + (= owner (get-in % [:actor :login])) + (= type (:event %))) + events))) (defn find-commit-id [user repo issue-number event-type] (-> (github/get-issue-events user repo issue-number) - (find-issue-event event-type) + (find-issue-event event-type user) (:commit_id))) (defn handle-issue-closed