do not insert empty goods
All checks were successful
Build and push image / deploy (push) Successful in 1m54s
All checks were successful
Build and push image / deploy (push) Successful in 1m54s
This commit is contained in:
@ -47,12 +47,17 @@ var sumpayCommand = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("GetGoods: %w", err)
|
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)
|
gormGoods := convertDigiGoodsToGorm(goods)
|
||||||
|
if len(gormGoods) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if err := db.Create(gormGoods).Error; err != nil {
|
if err := db.Create(gormGoods).Error; err != nil {
|
||||||
return fmt.Errorf("db Create: %w", err)
|
return fmt.Errorf("db Create: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("inserted %d goods to DB", len(gormGoods))
|
log.Printf("inserted %d goods to DB", len(gormGoods))
|
||||||
|
|
||||||
if len(goods.Rows.Row) < 500 {
|
if len(goods.Rows.Row) < 500 {
|
||||||
|
Reference in New Issue
Block a user