From 8b907a5ac2ebf07c77e3394db89e07644a0f1352 Mon Sep 17 00:00:00 2001 From: nquidox Date: Thu, 25 Sep 2025 18:33:09 +0300 Subject: [PATCH] time format change + days limit --- internal/api/merch/dto.go | 6 ++---- internal/api/merch/service.go | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-) 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, }) }