Add trailing '!' to 'remove' fns;
use enum instead of table for data type storage
This commit is contained in:
parent
23b532ee1a
commit
85bf4adc31
|
@ -1,2 +1,2 @@
|
||||||
DROP TABLE archive;
|
DROP TABLE archive;
|
||||||
DROP TABLE data_types;
|
DROP TYPE data_enum;
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
CREATE TABLE data_types (
|
CREATE TYPE data_enum AS ENUM (
|
||||||
name TEXT UNIQUE
|
'issue',
|
||||||
);
|
'issue_comment',
|
||||||
|
'repository',
|
||||||
INSERT INTO data_types(name)
|
'pull_request',
|
||||||
VALUES('issue'),
|
'user');
|
||||||
('issue_comment'),
|
|
||||||
('repository'),
|
|
||||||
('pull_request'),
|
|
||||||
('user');
|
|
||||||
|
|
||||||
CREATE TABLE archive (
|
CREATE TABLE archive (
|
||||||
type TEXT REFERENCES data_types(name),
|
type data_enum,
|
||||||
created_at TIMESTAMP DEFAULT now(),
|
created_at TIMESTAMP DEFAULT now(),
|
||||||
data JSONB
|
data JSONB
|
||||||
);
|
);
|
||||||
|
|
|
@ -65,15 +65,15 @@
|
||||||
(log/debug "Total issues for repo limit reached " repo " " count)
|
(log/debug "Total issues for repo limit reached " repo " " count)
|
||||||
(add-bounty-for-issue repo repo-id issue))))
|
(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
|
(let [{issue-id :id
|
||||||
issue-number :number} issue
|
issue-number :number} issue
|
||||||
removed-issue (issues/remove repo-id issue-id)
|
removed-issue (issues/remove! repo-id issue-id)
|
||||||
{owner-address :address
|
{owner-address :address
|
||||||
owner :owner} (users/get-repo-owner repo-id) ]
|
owner :owner} (users/get-repo-owner repo-id) ]
|
||||||
(log/debug "Removing bounty for issue " repo issue-number "owner address: " owner-address)
|
(log/debug "Removing bounty for issue " repo issue-number "owner address: " owner-address)
|
||||||
(if-let [comment-id (:comment_id removed-issue)]
|
(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"))))
|
(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
|
;; 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))))
|
(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)
|
(let [hash (github/github-comment-hash owner repo issue-number eth-balance)
|
||||||
issue-url (str owner "/" repo "/issues/" (str issue-number))
|
issue-url (str owner "/" repo "/issues/" (str issue-number))
|
||||||
png-data (png-rendering/gen-comment-image
|
png-data (png-rendering/gen-comment-image
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
:issue_number issue-number
|
:issue_number issue-number
|
||||||
:title issue-title})))
|
:title issue-title})))
|
||||||
|
|
||||||
(defn remove
|
(defn remove!
|
||||||
"Removes issue"
|
"Removes issue"
|
||||||
[repo-id issue-id]
|
[repo-id issue-id]
|
||||||
(jdbc/with-db-connection [con-db *db*]
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
|
|
|
@ -275,7 +275,7 @@
|
||||||
(log/debug "Posting comment to" (str owner "/" repo "/" issue-number) ":" comment)
|
(log/debug "Posting comment to" (str owner "/" repo "/" issue-number) ":" comment)
|
||||||
(issues/create-comment owner repo issue-number comment (self-auth-params))))
|
(issues/create-comment owner repo issue-number comment (self-auth-params))))
|
||||||
|
|
||||||
(defn remove-deploying-comment
|
(defn remove-deploying-comment!
|
||||||
[owner repo comment-id]
|
[owner repo comment-id]
|
||||||
(issues/delete-comment owner repo comment-id (self-auth-params)))
|
(issues/delete-comment owner repo comment-id (self-auth-params)))
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
repo-name :name} (:repository webhook-payload)]
|
repo-name :name} (:repository webhook-payload)]
|
||||||
(if label-added?
|
(if label-added?
|
||||||
(bounties/maybe-add-bounty-for-issue repo-name repo-id issue)
|
(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
|
(defn handle-issue-closed
|
||||||
[{{{owner :login} :owner repo :name} :repository
|
[{{{owner :login} :owner repo :name} :repository
|
||||||
|
|
Loading…
Reference in New Issue