Add share pointer to type Order
This commit is contained in:
parent
b8a759b141
commit
e6aec21aff
@ -50,7 +50,7 @@
|
||||
</tr>
|
||||
{{ range .Orders }}
|
||||
<tr>
|
||||
{{ if and (eq .ShareId $.YesShare.Id) (eq .Side "BUY") }}
|
||||
{{ if and (eq .Share.Description "YES") (eq .Side "BUY") }}
|
||||
<td>
|
||||
<div class="flex yes">
|
||||
<span class="align-left">YES</span>
|
||||
@ -60,27 +60,17 @@
|
||||
{{ else }}
|
||||
<td></td>
|
||||
{{ end }}
|
||||
{{ if and (eq .ShareId $.YesShare.Id) (eq .Side "SELL") }}
|
||||
{{ if (eq .Side "SELL") }}
|
||||
<td>
|
||||
<div class="flex no" style="width: 100%">
|
||||
<span class="align-left">YES</span>
|
||||
<span class="align-left">{{.Share.Description}}</span>
|
||||
<span style="width: 100%" class="align-right">{{.Quantity}} @ {{.Price}}</span>
|
||||
</div>
|
||||
</td>
|
||||
{{ else }}
|
||||
<td></td>
|
||||
{{ end }}
|
||||
{{ if and (eq .ShareId $.NoShare.Id) (eq .Side "SELL") }}
|
||||
<td>
|
||||
<div class="flex no">
|
||||
<span class="align-left">NO</span>
|
||||
<span style="width: 100%" class="align-right">{{.Quantity}} @ {{.Price}}</span>
|
||||
</div>
|
||||
</td>
|
||||
{{ else }}
|
||||
<td></td>
|
||||
{{ end }}
|
||||
{{ if and (eq .ShareId $.NoShare.Id) (eq .Side "BUY") }}
|
||||
{{ if and (eq .Share.Description "NO") (eq .Side "BUY") }}
|
||||
<td>
|
||||
<div class="flex yes">
|
||||
<span class="align-left">NO</span>
|
||||
|
@ -71,9 +71,10 @@ func (db *DB) FetchShares(marketId int, shares *[]Share) error {
|
||||
|
||||
func (db *DB) FetchOrders(marketId int, orders *[]Order) error {
|
||||
rows, err := db.Query(""+
|
||||
"SELECT o.id, share_id, o.pubkey, side, quantity, price, order_id "+
|
||||
"SELECT o.id, share_id, o.pubkey, o.side, o.quantity, o.price, s.description, o.order_id "+
|
||||
"FROM orders o "+
|
||||
"JOIN invoices i ON o.invoice_id = i.id "+
|
||||
"JOIN shares s ON o.share_id = s.id "+
|
||||
"WHERE share_id = ANY(SELECT id FROM shares WHERE market_id = $1) "+
|
||||
"AND i.confirmed_at IS NOT NULL "+
|
||||
"ORDER BY price DESC", marketId)
|
||||
@ -83,7 +84,7 @@ func (db *DB) FetchOrders(marketId int, orders *[]Order) error {
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var order Order
|
||||
rows.Scan(&order.Id, &order.ShareId, &order.Pubkey, &order.Side, &order.Quantity, &order.Price, &order.OrderId)
|
||||
rows.Scan(&order.Id, &order.ShareId, &order.Pubkey, &order.Side, &order.Quantity, &order.Price, &order.Share.Description, &order.OrderId)
|
||||
*orders = append(*orders, order)
|
||||
}
|
||||
return nil
|
||||
|
@ -25,6 +25,7 @@ type Share struct {
|
||||
|
||||
type Order struct {
|
||||
Session
|
||||
Share
|
||||
Id string
|
||||
ShareId string `form:"share_id"`
|
||||
Side string `form:"side"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user