This commit is contained in:
2023-12-21 22:13:18 +03:00
parent a6f51d94a0
commit 85a42dc405
2 changed files with 7 additions and 1 deletions

View File

@ -34,7 +34,7 @@ var platiCommand = &cli.Command{
// printNames(categories) // printNames(categories)
wg, _ := errgroup.WithContext(ctx) wg, _ := errgroup.WithContext(ctx)
wg.SetLimit(30) wg.SetLimit(10)
for i, c := range categories { for i, c := range categories {
l := i l := i
@ -48,6 +48,8 @@ var platiCommand = &cli.Command{
if len(goods) == 0 { if len(goods) == 0 {
return nil return nil
} }
log.Printf("inserting %d goods to DB", len(goods))
gormGoods := convertGoodsToGorm(cat, goods) gormGoods := convertGoodsToGorm(cat, goods)
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)

View File

@ -34,6 +34,10 @@ func (c *Client) GetBlockGoodsCategory(ctx context.Context, idC int, idR int, so
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("status code: %d", resp.StatusCode)
}
goods, err := parseGoodsCategory(resp.Body) goods, err := parseGoodsCategory(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("parse goods category: %w", err) return nil, fmt.Errorf("parse goods category: %w", err)