New Quotator and some major changes to pricing admin

This commit is contained in:
Mikhail Chusavitin
2026-01-26 18:30:45 +03:00
parent a93644131c
commit d7d6e9d62c
24 changed files with 565 additions and 112 deletions

View File

@@ -3,7 +3,7 @@ package repository
import (
"time"
"github.com/mchus/quoteforge/internal/models"
"git.mchus.pro/mchus/quoteforge/internal/models"
"gorm.io/gorm"
)
@@ -97,3 +97,28 @@ func (r *PriceRepository) GetQuoteCount(lotName string, periodDays int) (int64,
return count, err
}
// GetQuoteCounts returns quote counts for multiple lot names
func (r *PriceRepository) GetQuoteCounts(lotNames []string) (map[string]int64, error) {
type Result struct {
Lot string
Count int64
}
var results []Result
err := r.db.Model(&models.LotLog{}).
Select("lot, COUNT(*) as count").
Where("lot IN ?", lotNames).
Group("lot").
Scan(&results).Error
if err != nil {
return nil, err
}
counts := make(map[string]int64)
for _, r := range results {
counts[r.Lot] = r.Count
}
return counts, nil
}