feat: improve admin pricing modal quote count display to show period and total counts
This commit is contained in:
@@ -708,8 +708,8 @@ func (h *PricingHandler) PreviewPrice(c *gin.Context) {
|
||||
medianAllTime = &median
|
||||
}
|
||||
|
||||
// Get quote count (from all relevant lots)
|
||||
var quoteCount int64
|
||||
// Get quote count (from all relevant lots) - total count
|
||||
var quoteCountTotal int64
|
||||
for _, lotName := range lotNames {
|
||||
var count int64
|
||||
if strings.HasSuffix(lotName, "*") {
|
||||
@@ -718,7 +718,25 @@ func (h *PricingHandler) PreviewPrice(c *gin.Context) {
|
||||
} else {
|
||||
h.db.Model(&models.LotLog{}).Where("lot = ?", lotName).Count(&count)
|
||||
}
|
||||
quoteCount += count
|
||||
quoteCountTotal += count
|
||||
}
|
||||
|
||||
// Get quote count for specified period (if period is > 0)
|
||||
var quoteCountPeriod int64
|
||||
if req.PeriodDays > 0 {
|
||||
for _, lotName := range lotNames {
|
||||
var count int64
|
||||
if strings.HasSuffix(lotName, "*") {
|
||||
pattern := strings.TrimSuffix(lotName, "*") + "%"
|
||||
h.db.Raw(`SELECT COUNT(*) FROM lot_log WHERE lot LIKE ? AND date >= DATE_SUB(NOW(), INTERVAL ? DAY)`, pattern, req.PeriodDays).Scan(&count)
|
||||
} else {
|
||||
h.db.Raw(`SELECT COUNT(*) FROM lot_log WHERE lot = ? AND date >= DATE_SUB(NOW(), INTERVAL ? DAY)`, lotName, req.PeriodDays).Scan(&count)
|
||||
}
|
||||
quoteCountPeriod += count
|
||||
}
|
||||
} else {
|
||||
// If no period specified, period count equals total count
|
||||
quoteCountPeriod = quoteCountTotal
|
||||
}
|
||||
|
||||
// Get last received price (from the main lot only)
|
||||
@@ -773,14 +791,15 @@ func (h *PricingHandler) PreviewPrice(c *gin.Context) {
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"lot_name": req.LotName,
|
||||
"current_price": comp.CurrentPrice,
|
||||
"median_all_time": medianAllTime,
|
||||
"new_price": newPrice,
|
||||
"quote_count": quoteCount,
|
||||
"manual_price": comp.ManualPrice,
|
||||
"last_price": lastPrice.Price,
|
||||
"last_price_date": lastPrice.Date,
|
||||
"lot_name": req.LotName,
|
||||
"current_price": comp.CurrentPrice,
|
||||
"median_all_time": medianAllTime,
|
||||
"new_price": newPrice,
|
||||
"quote_count_total": quoteCountTotal,
|
||||
"quote_count_period": quoteCountPeriod,
|
||||
"manual_price": comp.ManualPrice,
|
||||
"last_price": lastPrice.Price,
|
||||
"last_price_date": lastPrice.Date,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user