threads
This commit is contained in:
@ -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)
|
||||||
|
@ -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)
|
||||||
|
Reference in New Issue
Block a user