allow to skip item by created

This commit is contained in:
Aleksandr Trushkin
2024-02-04 22:13:39 +03:00
parent a224f249d5
commit e91eec7aeb
7 changed files with 51 additions and 3 deletions

View File

@ -248,18 +248,20 @@ func (c *goodsItemClient) upsertByBatch(ctx context.Context, items []entity.Good
batch := c.db.NewWriteBatch()
defer batch.Cancel()
createdAt := time.Now()
err := func() error {
for _, item := range items {
if ctx.Err() != nil {
return ctx.Err()
}
key := c.prefixedStr(item.Articul)
item.CreatedAt = createdAt
value, err := c.s.Serialize(item)
if err != nil {
return fmt.Errorf("serializing item: %w", err)
}
key := c.prefixedStr(item.Articul)
idxValue := make([]byte, len(key))
copy(idxValue, key)