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