Formatting

This commit is contained in:
Kevin Cotugno 2017-09-08 08:45:22 -07:00
parent eb0c79942c
commit 31cf9cdf10

View File

@ -7,20 +7,19 @@ import (
)
const (
trade_insert = `INSERT INTO trades (trade_id, product, price, size, buy, ` +
`sell, timestamp) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id;`
trade_find = `SELECT id, trade_id, product, price, size, buy, sell, ` +
`timestamp FROM trades WHERE id = $1;`
trade_find_trade_id = `SELECT id, trade_id, product, price, size, buy, ` +
`sell, timestamp FROM trades WHERE trade_id = $1 AND product = $2;`
trade_delete = `DELETE FROM trades WHERE id = $1;`
trades_in_date_range = `SELECT id, trade_id, product, price, size, buy, ` +
`sell, timestamp FROM trades WHERE product = $1 AND timestamp >= $2 ` +
`AND timestamp < $3;`
trade_first = `SELECT id, trade_id, product, price, size, buy, sell, timestamp ` +
`FROM trades WHERE product = $1 ORDER BY trade_id ASC LIMIT 1;`
trade_last = `SELECT id, trade_id, product, price, size, buy, sell, timestamp ` +
`FROM trades WHERE product = $1 ORDER BY trade_id DESC LIMIT 1;`
trade_columns = `trade_id, product, price, size, buy, sell, timestamp`
trade_insert = `INSERT INTO trades (` + trade_columns + `) VALUES ` +
`($1, $2, $3, $4, $5, $6, $7) RETURNING id;`
trade_find = `SELECT id, ` + trade_columns + ` FROM trades WHERE id = $1;`
trade_find_trade_id = `SELECT id, ` + trade_columns + ` FROM trades ` +
`WHERE trade_id = $1 AND product = $2;`
trade_delete = `DELETE FROM trades WHERE id = $1;`
trades_in_date_range = `SELECT id, ` + trade_columns + ` FROM ` +
`trades WHERE product = $1 AND timestamp >= $2 AND timestamp < $3;`
trade_first = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` +
`product = $1 ORDER BY trade_id ASC LIMIT 1;`
trade_last = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` +
`product = $1 ORDER BY trade_id DESC LIMIT 1;`
)
type TradeService struct {
@ -44,8 +43,8 @@ func (t *TradeService) TradeByTradeId(id int, prod string) (*tacitus.Trade, erro
var tr tacitus.Trade
row := t.client.db.QueryRow(trade_find_trade_id, id, prod)
if err := row.Scan(&tr.Id, &tr.TradeId, &tr.Product, &tr.Price, &tr.Size, &tr.Buy,
&tr.Sell, &tr.Timestamp); err != nil {
if err := row.Scan(&tr.Id, &tr.TradeId, &tr.Product, &tr.Price,
&tr.Size, &tr.Buy, &tr.Sell, &tr.Timestamp); err != nil {
return nil, err
}