time format change + days limit

This commit is contained in:
nquidox 2025-09-25 18:33:09 +03:00
parent cbc7352a36
commit 8b907a5ac2
2 changed files with 7 additions and 5 deletions

View file

@ -1,7 +1,5 @@
package merch
import "time"
type merchBundle struct {
Merch *Merch
Surugaya *Surugaya
@ -34,8 +32,8 @@ type ListResponse struct {
}
type PriceEntry struct {
CreatedAt time.Time `json:"created_at"`
Value int `json:"value"`
CreatedAt int64 `json:"created_at"`
Value int `json:"value"`
}
type OriginWithPrices struct {

View file

@ -103,6 +103,10 @@ func (s *service) getPrices(userUuid string, days string) ([]PricesResponse, err
daysInt = 7
}
if daysInt > 365 {
daysInt = 7
}
period := time.Now().UTC().Add(-(time.Duration(daysInt) * time.Hour * 24))
pricesList, err := s.repo.getPricesWithDays(userUuid, period)
@ -117,7 +121,7 @@ func (s *service) getPrices(userUuid string, days string) ([]PricesResponse, err
}
pricesMap[item.MerchUuid][item.Origin] = append(pricesMap[item.MerchUuid][item.Origin], PriceEntry{
CreatedAt: item.CreatedAt,
CreatedAt: item.CreatedAt.Unix(),
Value: item.Price,
})
}