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
|
package merch
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
type merchBundle struct {
|
type merchBundle struct {
|
||||||
Merch *Merch
|
Merch *Merch
|
||||||
Surugaya *Surugaya
|
Surugaya *Surugaya
|
||||||
|
|
@ -34,8 +32,8 @@ type ListResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PriceEntry struct {
|
type PriceEntry struct {
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
Value int `json:"value"`
|
Value int `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OriginWithPrices struct {
|
type OriginWithPrices struct {
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,10 @@ func (s *service) getPrices(userUuid string, days string) ([]PricesResponse, err
|
||||||
daysInt = 7
|
daysInt = 7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if daysInt > 365 {
|
||||||
|
daysInt = 7
|
||||||
|
}
|
||||||
|
|
||||||
period := time.Now().UTC().Add(-(time.Duration(daysInt) * time.Hour * 24))
|
period := time.Now().UTC().Add(-(time.Duration(daysInt) * time.Hour * 24))
|
||||||
|
|
||||||
pricesList, err := s.repo.getPricesWithDays(userUuid, period)
|
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{
|
pricesMap[item.MerchUuid][item.Origin] = append(pricesMap[item.MerchUuid][item.Origin], PriceEntry{
|
||||||
CreatedAt: item.CreatedAt,
|
CreatedAt: item.CreatedAt.Unix(),
|
||||||
Value: item.Price,
|
Value: item.Price,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue