diff --git a/resources/migrations/20180130164001-archive.down.sql b/resources/migrations/20180130164001-archive.down.sql index 2f9f372..cf10a6e 100644 --- a/resources/migrations/20180130164001-archive.down.sql +++ b/resources/migrations/20180130164001-archive.down.sql @@ -1,2 +1,2 @@ DROP TABLE archive; -DROP TABLE data_types; +DROP TYPE data_enum; diff --git a/resources/migrations/20180130164001-archive.up.sql b/resources/migrations/20180130164001-archive.up.sql index cf35c6e..fb53881 100644 --- a/resources/migrations/20180130164001-archive.up.sql +++ b/resources/migrations/20180130164001-archive.up.sql @@ -1,16 +1,12 @@ -CREATE TABLE data_types ( - name TEXT UNIQUE -); - -INSERT INTO data_types(name) - VALUES('issue'), - ('issue_comment'), - ('repository'), - ('pull_request'), - ('user'); +CREATE TYPE data_enum AS ENUM ( + 'issue', + 'issue_comment', + 'repository', + 'pull_request', + 'user'); CREATE TABLE archive ( - type TEXT REFERENCES data_types(name), + type data_enum, created_at TIMESTAMP DEFAULT now(), data JSONB ); diff --git a/src/clj/commiteth/bounties.clj b/src/clj/commiteth/bounties.clj index 983e619..d61a449 100644 --- a/src/clj/commiteth/bounties.clj +++ b/src/clj/commiteth/bounties.clj @@ -65,15 +65,15 @@ (log/debug "Total issues for repo limit reached " repo " " count) (add-bounty-for-issue repo repo-id issue)))) -(defn remove-bounty-for-issue [repo repo-id issue] +(defn remove-bounty-for-issue! [repo repo-id issue] (let [{issue-id :id issue-number :number} issue - removed-issue (issues/remove repo-id issue-id) + removed-issue (issues/remove! repo-id issue-id) {owner-address :address owner :owner} (users/get-repo-owner repo-id) ] (log/debug "Removing bounty for issue " repo issue-number "owner address: " owner-address) (if-let [comment-id (:comment_id removed-issue)] - (github/remove-deploying-comment owner repo comment-id) + (github/remove-deploying-comment! owner repo comment-id) (log/debug "Cannot remove Github bounty comment as it has non-zero value")))) ;; We have a max-limit to ensure people can't add more issues and @@ -91,7 +91,9 @@ (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] +(defn update-bounty-comment-image [issue-id owner repo + issue-number contract-address + eth-balance eth-balance-str tokens] (let [hash (github/github-comment-hash owner repo issue-number eth-balance) issue-url (str owner "/" repo "/issues/" (str issue-number)) png-data (png-rendering/gen-comment-image diff --git a/src/clj/commiteth/db/issues.clj b/src/clj/commiteth/db/issues.clj index 4540444..4f6d278 100644 --- a/src/clj/commiteth/db/issues.clj +++ b/src/clj/commiteth/db/issues.clj @@ -12,7 +12,7 @@ :issue_number issue-number :title issue-title}))) -(defn remove +(defn remove! "Removes issue" [repo-id issue-id] (jdbc/with-db-connection [con-db *db*] diff --git a/src/clj/commiteth/github/core.clj b/src/clj/commiteth/github/core.clj index 56fff8f..06df9ef 100644 --- a/src/clj/commiteth/github/core.clj +++ b/src/clj/commiteth/github/core.clj @@ -275,7 +275,7 @@ (log/debug "Posting comment to" (str owner "/" repo "/" issue-number) ":" comment) (issues/create-comment owner repo issue-number comment (self-auth-params)))) -(defn remove-deploying-comment +(defn remove-deploying-comment! [owner repo comment-id] (issues/delete-comment owner repo comment-id (self-auth-params))) diff --git a/src/clj/commiteth/routes/webhooks.clj b/src/clj/commiteth/routes/webhooks.clj index e00e762..10e87e1 100644 --- a/src/clj/commiteth/routes/webhooks.clj +++ b/src/clj/commiteth/routes/webhooks.clj @@ -48,7 +48,7 @@ repo-name :name} (:repository webhook-payload)] (if label-added? (bounties/maybe-add-bounty-for-issue repo-name repo-id issue) - (bounties/remove-bounty-for-issue repo-name repo-id issue)))) + (bounties/remove-bounty-for-issue! repo-name repo-id issue)))) (defn handle-issue-closed [{{{owner :login} :owner repo :name} :repository