Fix query for lmsr.Q1 & lmsr.Q2

This commit is contained in:
ekzyis 2024-08-26 05:55:19 -05:00
parent 3075f12fc1
commit 5587aeb03a
1 changed files with 4 additions and 4 deletions

View File

@ -137,8 +137,8 @@ func HandleMarket(sc context.Context) echo.HandlerFunc {
if err = db.QueryRowContext(ctx, ""+ if err = db.QueryRowContext(ctx, ""+
"SELECT "+ "SELECT "+
"COUNT(o.quantity) FILTER(WHERE o.outcome = 0) AS q1, "+ "COALESCE(SUM(o.quantity) FILTER(WHERE o.outcome = 0), 0) AS q1, "+
"COUNT(o.quantity) FILTER(WHERE o.outcome = 1) AS q2 "+ "COALESCE(SUM(o.quantity) FILTER(WHERE o.outcome = 1), 0) AS q2 "+
"FROM orders o "+ "FROM orders o "+
"JOIN markets m ON o.market_id = m.id "+ "JOIN markets m ON o.market_id = m.id "+
"JOIN invoices i ON o.invoice_id = i.id "+ "JOIN invoices i ON o.invoice_id = i.id "+
@ -244,8 +244,8 @@ func HandleOrder(sc context.Context) echo.HandlerFunc {
if err = db.QueryRowContext(ctx, ""+ if err = db.QueryRowContext(ctx, ""+
"SELECT "+ "SELECT "+
"COUNT(o.quantity) FILTER(WHERE o.outcome = 0) AS q1, "+ "COALESCE(SUM(o.quantity) FILTER(WHERE o.outcome = 0), 0) AS q1, "+
"COUNT(o.quantity) FILTER(WHERE o.outcome = 1) AS q2 "+ "COALESCE(SUM(o.quantity) FILTER(WHERE o.outcome = 1), 0) AS q2 "+
"FROM orders o "+ "FROM orders o "+
"JOIN markets m ON o.market_id = m.id "+ "JOIN markets m ON o.market_id = m.id "+
"JOIN invoices i ON o.invoice_id = i.id "+ "JOIN invoices i ON o.invoice_id = i.id "+