do not insert empty goods
All checks were successful
Build and push image / deploy (push) Successful in 1m54s

This commit is contained in:
2023-12-27 18:30:54 +03:00
parent 50d59f6452
commit c1e8c597bc

View File

@ -47,12 +47,17 @@ var sumpayCommand = &cli.Command{
if err != nil {
return fmt.Errorf("GetGoods: %w", err)
}
log.Printf("got page %d/%d, inserting %d goods to DB", goods.Page, goods.Pages, len(goods.Rows.Row))
log.Printf("got page [%d/%d], inserting %d goods to DB", goods.Page, goods.Pages, len(goods.Rows.Row))
gormGoods := convertDigiGoodsToGorm(goods)
if len(gormGoods) == 0 {
break
}
if err := db.Create(gormGoods).Error; err != nil {
return fmt.Errorf("db Create: %w", err)
}
log.Printf("inserted %d goods to DB", len(gormGoods))
if len(goods.Rows.Row) < 500 {