time format change + days limit
This commit is contained in:
parent
cbc7352a36
commit
8b907a5ac2
2 changed files with 7 additions and 5 deletions
|
|
@ -1,7 +1,5 @@
|
|||
package merch
|
||||
|
||||
import "time"
|
||||
|
||||
type merchBundle struct {
|
||||
Merch *Merch
|
||||
Surugaya *Surugaya
|
||||
|
|
@ -34,7 +32,7 @@ type ListResponse struct {
|
|||
}
|
||||
|
||||
type PriceEntry struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
Value int `json:"value"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue