Add trailing '!' to 'remove' fns;

use enum instead of table for data type storage
This commit is contained in:
Vitaliy Vlasov 2018-02-08 16:27:52 +02:00
parent 23b532ee1a
commit 85bf4adc31
6 changed files with 17 additions and 19 deletions

View File

@ -1,2 +1,2 @@
DROP TABLE archive;
DROP TABLE data_types;
DROP TYPE data_enum;

View File

@ -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
);

View File

@ -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

View File

@ -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*]

View File

@ -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)))

View File

@ -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