update
Some checks failed
Build and Publish / Metadata (push) Successful in 16s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m0s
Build and Publish / BuildAndDeployArm64 (push) Has been cancelled

This commit is contained in:
2025-11-13 21:52:29 +01:00
parent af5d4cd325
commit e25ca3304e
7 changed files with 110 additions and 37 deletions

View File

@@ -21,6 +21,7 @@ type StockHandler struct {
func (s *StockHandler) HandleItem(item types.Item, wg *sync.WaitGroup) {
wg.Go(func() {
ctx := s.ctx
pipe := s.rdb.Pipeline()
centralStockString, ok := item.GetStringFieldValue(3)
if !ok {
@@ -35,12 +36,12 @@ func (s *StockHandler) HandleItem(item types.Item, wg *sync.WaitGroup) {
log.Printf("unable to parse central stock for item %s: %v", item.GetSku(), err)
centralStock = 0
} else {
s.svc.UpdateInventory(pipe, inventory.SKU(item.GetSku()), s.MainStockLocationID, int64(centralStock))
s.svc.UpdateInventory(ctx, pipe, inventory.SKU(item.GetSku()), s.MainStockLocationID, int64(centralStock))
}
for id, value := range item.GetStock() {
s.svc.UpdateInventory(pipe, inventory.SKU(item.GetSku()), inventory.LocationID(id), int64(value))
s.svc.UpdateInventory(ctx, pipe, inventory.SKU(item.GetSku()), inventory.LocationID(id), int64(value))
}
_, err = pipe.Exec(s.ctx)
_, err = pipe.Exec(ctx)
if err != nil {
log.Printf("unable to update stock: %v", err)
}