Fix issues with db field renaming

This commit is contained in:
Vitaliy Vlasov 2018-05-18 19:54:12 +03:00
parent bbf96cc497
commit 329e73e906
No known key found for this signature in database
GPG Key ID: A7D57C347F2B2964
6 changed files with 27 additions and 26 deletions

View File

@ -365,9 +365,9 @@ WHERE watch_hash IS NOT NULL;
-- :name update-payout-hash :! :n
-- :doc updates issue with payout transaction hash
UPDATE issues
SET payout_hash = :payout-hash,
SET payout_hash = :payout_hash,
updated = timezone('utc'::text, now())
WHERE issue_id = :issue-id;
WHERE issue_id = :issue_id;
-- :name reset-payout-hash :! :n
-- :doc sets issue's payout transaction hash to NULL
@ -380,9 +380,9 @@ WHERE issue_id = :issue_id;
-- :name update-payout-receipt :! :n
-- :doc updates issue with payout transaction receipt
UPDATE issues
SET payout_receipt = :payout-receipt::jsonb,
SET payout_receipt = :payout_receipt::jsonb,
updated = timezone('utc'::text, now())
WHERE issue_id = :issue-id;
WHERE issue_id = :issue_id;
-- :name update-issue-open :! :n
-- :doc updates issue's open status
@ -556,7 +556,7 @@ SELECT
r.owner AS owner,
r.repo AS repo
FROM issues i, repositories r
WHERE i.issue_number = :issue-number
WHERE i.issue_number = :issue_number
AND r.repo_id = i.repo_id
AND r.owner = :owner
AND r.repo = :repo;
@ -564,11 +564,11 @@ AND r.repo = :repo;
-- :name update-balances :! :n
-- :doc updates balance of a wallet attached to a given issue
UPDATE issues
SET balance_eth = :balance-eth,
tokens = :token-balances::jsonb,
value_usd = :usd-value,
SET balance_eth = :balance_eth,
tokens = :token_balances::jsonb,
value_usd = :usd_value,
updated = timezone('utc'::text, now())
WHERE contract_address = :contract-address;
WHERE contract_address = :contract_address;
-- :name save-issue-comment-image! :<! :1

View File

@ -58,13 +58,15 @@
(tracker/untrack-tx! tx-info)
:update-balances
(issues/update-balances (:contract-address bounty)
(:balance-eth bounty)
(:tokens bounty)
(:value-usd bounty))
(do
(github/update-bounty-comment-image bounty)
(issues/update-balances (:contract-address bounty)
(:balance-eth bounty)
(:tokens bounty)
(:value-usd bounty)))
)
(github/update-comment bounty state))))
(github/update-comment bounty state))))
(defn deploy-contract [owner-address issue-id]
(if (empty? owner-address)
(log/errorf "issue %s: Unable to deploy bounty contract because repo owner has no Ethereum addres" issue-id)

View File

@ -1,6 +1,7 @@
(ns commiteth.db.bounties
(:require [commiteth.db.core :refer [*db*] :as db]
[commiteth.util.util :refer [to-db-map]]
[clojure.tools.logging :as log]
[clojure.java.jdbc :as jdbc]
[clojure.set :refer [rename-keys]]))
@ -69,6 +70,7 @@
(defn get-bounty
[owner repo issue-number]
(jdbc/with-db-connection [con-db *db*]
(log/info "get-bounty params:" (to-db-map owner repo issue-number))
(db/get-bounty con-db (to-db-map owner repo issue-number))))
(defn open-bounty-contracts

View File

@ -76,9 +76,9 @@
[contract-address balance-eth token-balances usd-value]
(jdbc/with-db-connection [con-db *db*]
(db/update-balances con-db (to-db-map contract-address
balance-eth
token-balances
usd-value))))
balance-eth
token-balances
usd-value))))
(defn update-open-status
[issue-id is-open]

View File

@ -338,7 +338,7 @@
(let [comment (case state
:deploying
(generate-deploying-comment owner repo issue-number transaction-hash)
:opened
(:opened :update-balances)
(generate-open-comment owner
repo
issue-number

View File

@ -12,21 +12,18 @@
(context "/qr" []
(GET "/:owner/:repo/bounty/:issue{[0-9]{1,9}}/:hash/qr.png" [owner repo issue hash]
(log/debug "qr PNG GET" owner repo issue hash)
(if-let [{address :contract_address
repo :repo
issue-id :issue_id
balance-eth :balance_eth}
(if-let [{:keys [contract-address repo issue-id balance-eth]}
(bounties/get-bounty owner
repo
(Integer/parseInt issue))]
(do
(log/debug "address:" address)
(log/debug "address:" contract-address)
(log/debug owner repo issue balance-eth)
(log/debug hash (github/github-comment-hash owner repo issue balance-eth))
(if address
(if-let [{png-data :png_data}
(if contract-address
(if-let [{:keys [png-data]}
(comment-images/get-image-data
issue-id hash)]
issue-id hash)]
(do (log/debug "PNG found")
{:status 200
:content-type "image/png"