diff --git a/internal/api/merch/dto.go b/internal/api/merch/dto.go index f8d1630..cce0e03 100644 --- a/internal/api/merch/dto.go +++ b/internal/api/merch/dto.go @@ -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 { diff --git a/internal/api/merch/service.go b/internal/api/merch/service.go index 4470e43..ae9384c 100644 --- a/internal/api/merch/service.go +++ b/internal/api/merch/service.go @@ -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, }) }