Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7916c81ece | ||
|
|
f84d20ba20 |
@@ -20,14 +20,15 @@ func GetTopItems(c *gin.Context) {
|
||||
results := []TopItem{}
|
||||
|
||||
err := database.DB.Table("order_items").
|
||||
Select("items.name, SUM(order_items.price * order_items.quantity) AS revenue, order_items.price, SUM(order_items.quantity) as sale_quantity, items.unit").
|
||||
Select("items.name, SUM(order_items.price * order_items.quantity) AS revenue, AVG(order_items.price) as price, SUM(order_items.quantity) as sale_quantity, items.unit").
|
||||
Joins("JOIN items ON items.id = order_items.item_id").
|
||||
Group("items.name, order_items.price, items.unit").
|
||||
Group("items.name, items.unit").
|
||||
Order("revenue DESC").
|
||||
Limit(5).
|
||||
Scan(&results).Error
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, results)
|
||||
|
||||
@@ -25,7 +25,7 @@ export default function AdminPage() {
|
||||
</h1>
|
||||
|
||||
{/* Вкладки */}
|
||||
<div className="flex gap-2 mb-8 border-b border-white/10">
|
||||
<div className="flex overflow-x-auto whitespace-nowrap gap-2 mb-8 border-b border-white/10">
|
||||
{tabs.map((t) => (
|
||||
<button
|
||||
key={t.key}
|
||||
|
||||
Reference in New Issue
Block a user