insert prices change
This commit is contained in:
parent
db9684debc
commit
544c5348f1
3 changed files with 10 additions and 10 deletions
|
|
@ -2,6 +2,7 @@ package merch
|
|||
|
||||
import (
|
||||
"context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"merch-api/internal/common"
|
||||
"merch-api/pkg/utils"
|
||||
)
|
||||
|
|
@ -30,6 +31,7 @@ func (p *provider) GetTasks(ctx context.Context) ([]common.Task, error) {
|
|||
}
|
||||
|
||||
func (p *provider) InsertPrices(ctx context.Context, rawPrices []common.Result) error {
|
||||
log.WithField("payload", rawPrices).Debugf("%v Inserting prices", providerLogHeader)
|
||||
if rawPrices == nil || len(rawPrices) == 0 {
|
||||
logDebug(providerLogHeader, "no prices given")
|
||||
return nil
|
||||
|
|
@ -56,15 +58,13 @@ func (p *provider) InsertPrices(ctx context.Context, rawPrices []common.Result)
|
|||
var insertPrices []Price
|
||||
for _, rawPrice := range rawPrices {
|
||||
insertPrices = append(insertPrices, Price{
|
||||
CreatedAt: now,
|
||||
UpdatedAt: p.utils.NullTimeFromNow(now),
|
||||
MerchId: uuidMap[rawPrice.MerchUuid],
|
||||
OriginId: originIds[rawPrice.OriginName],
|
||||
Price: int(rawPrice.Price),
|
||||
MerchId: uuidMap[rawPrice.MerchUuid],
|
||||
OriginId: originIds[rawPrice.OriginName],
|
||||
Price: int(rawPrice.Price),
|
||||
})
|
||||
}
|
||||
|
||||
if err = p.service.repo.insertPrices(ctx, insertPrices); err != nil {
|
||||
if err = p.service.repo.insertPrices(ctx, now, p.utils.NullTimeFromNow(now), insertPrices); err != nil {
|
||||
logErr(serviceLogHeader, err)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue