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