chore: build

This commit is contained in:
2026-06-12 09:43:29 +02:00
parent 13df186854
commit 2ca28e730b
4 changed files with 79 additions and 17 deletions
+43 -11
View File
@@ -40,16 +40,35 @@ func GetMyPointsRewards(c *gin.Context) {
reward := settings.PointsReward
type PoolInfo struct {
Key string `json:"key"`
Name string `json:"name"`
Points int `json:"points"`
RewardsEarned int `json:"rewards_earned"`
RewardsClaimed int `json:"rewards_claimed"`
RewardsAvailable int `json:"rewards_available"`
EligibleConfigs []models.RewardCategoryConfig `json:"eligible_configs"`
type EligibleConfigResponse struct {
Category string `json:"category"`
AllProducts bool `json:"all_products"`
ProductIDs []int `json:"product_ids"`
ProductNames []string `json:"product_names"`
Amount float64 `json:"amount"`
}
type PoolInfo struct {
Key string `json:"key"`
Name string `json:"name"`
Points int `json:"points"`
RewardsEarned int `json:"rewards_earned"`
RewardsClaimed int `json:"rewards_claimed"`
RewardsAvailable int `json:"rewards_available"`
EligibleConfigs []EligibleConfigResponse `json:"eligible_configs"`
}
// Collecter tous les product_ids nécessaires en un seul passage
allProductIDs := make([]int, 0)
if reward != nil {
for _, cfg := range reward.CategoryConfigs {
if !cfg.AllProducts {
allProductIDs = append(allProductIDs, cfg.ProductIDs...)
}
}
}
productNames, _ := database.GetProductNamesByIDs(allProductIDs)
pools := make([]PoolInfo, 0, len(settings.PointsPools))
for _, pool := range settings.PointsPools {
pts := pointsExtra[pool.Key]
@@ -69,12 +88,25 @@ func GetMyPointsRewards(c *gin.Context) {
for _, c := range pool.Categories {
poolCats[c] = true
}
eligibleConfigs := make([]models.RewardCategoryConfig, 0)
eligibleConfigs := make([]EligibleConfigResponse, 0)
if reward != nil {
for _, cfg := range reward.CategoryConfigs {
if poolCats[cfg.Category] {
eligibleConfigs = append(eligibleConfigs, cfg)
if !poolCats[cfg.Category] {
continue
}
names := make([]string, 0, len(cfg.ProductIDs))
for _, pid := range cfg.ProductIDs {
if n, ok := productNames[pid]; ok {
names = append(names, n)
}
}
eligibleConfigs = append(eligibleConfigs, EligibleConfigResponse{
Category: cfg.Category,
AllProducts: cfg.AllProducts,
ProductIDs: cfg.ProductIDs,
ProductNames: names,
Amount: cfg.Amount,
})
}
}