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

View File

@ -58,10 +58,12 @@
(tracker/untrack-tx! tx-info) (tracker/untrack-tx! tx-info)
:update-balances :update-balances
(do
(github/update-bounty-comment-image bounty)
(issues/update-balances (:contract-address bounty) (issues/update-balances (:contract-address bounty)
(:balance-eth bounty) (:balance-eth bounty)
(:tokens bounty) (:tokens bounty)
(:value-usd bounty)) (:value-usd bounty)))
) )
(github/update-comment bounty state)))) (github/update-comment bounty state))))

View File

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

View File

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

View File

@ -12,19 +12,16 @@
(context "/qr" [] (context "/qr" []
(GET "/:owner/:repo/bounty/:issue{[0-9]{1,9}}/:hash/qr.png" [owner repo issue hash] (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) (log/debug "qr PNG GET" owner repo issue hash)
(if-let [{address :contract_address (if-let [{:keys [contract-address repo issue-id balance-eth]}
repo :repo
issue-id :issue_id
balance-eth :balance_eth}
(bounties/get-bounty owner (bounties/get-bounty owner
repo repo
(Integer/parseInt issue))] (Integer/parseInt issue))]
(do (do
(log/debug "address:" address) (log/debug "address:" contract-address)
(log/debug owner repo issue balance-eth) (log/debug owner repo issue balance-eth)
(log/debug hash (github/github-comment-hash owner repo issue balance-eth)) (log/debug hash (github/github-comment-hash owner repo issue balance-eth))
(if address (if contract-address
(if-let [{png-data :png_data} (if-let [{:keys [png-data]}
(comment-images/get-image-data (comment-images/get-image-data
issue-id hash)] issue-id hash)]
(do (log/debug "PNG found") (do (log/debug "PNG found")