Skip to content
This repository has been archived by the owner on Apr 26, 2019. It is now read-only.

Commit

Permalink
Add trailing '!' to 'remove' fns;
Browse files Browse the repository at this point in the history
use enum instead of table for data type storage
  • Loading branch information
Vitaliy Vlasov committed Feb 8, 2018
1 parent 23b532e commit 85bf4ad
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion resources/migrations/20180130164001-archive.down.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DROP TABLE archive;
DROP TABLE data_types;
DROP TYPE data_enum;
18 changes: 7 additions & 11 deletions resources/migrations/20180130164001-archive.up.sql
Original file line number Diff line number Diff line change
@@ -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
);
Expand Down
10 changes: 6 additions & 4 deletions src/clj/commiteth/bounties.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/clj/commiteth/db/issues.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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*]
Expand Down
2 changes: 1 addition & 1 deletion src/clj/commiteth/github/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down
2 changes: 1 addition & 1 deletion src/clj/commiteth/routes/webhooks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85bf4ad

Please sign in to comment.