seller id deadlock and delete elapsed time
This commit is contained in:
parent
190306d902
commit
3693589d66
|
|
@ -592,11 +592,15 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
|||
|
||||
}
|
||||
|
||||
errFlat := db.Omit("ParentID", "CreatedAt", "Variants").Save(&mainProductFlat)
|
||||
var errFlat error
|
||||
if mainProductFlat.SpecialPrice != 0 {
|
||||
errFlat = db.Omit("ParentID", "CreatedAt", "Variants").Save(&mainProductFlat).Error
|
||||
} else {
|
||||
errFlat = db.Omit("ParentID", "CreatedAt", "Variants", "SpecialPrice").Save(&mainProductFlat).Error
|
||||
}
|
||||
|
||||
if errFlat != nil {
|
||||
log.Println(errFlat)
|
||||
|
||||
}
|
||||
|
||||
sProduct := createSellerProduct(&mainProductFlat, product.Vendor)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ func DeleteProducts(db *gorm.DB) error {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
defer cancel()
|
||||
//qb := "DELETE FROM products WHERE id NOT IN (select product_id as id from wishlist) AND id NOT IN (select product_id as id from order_items) AND id NOT IN (select parent_id as idfrom order_items);"
|
||||
qb := "DELETE p FROM products p LEFT JOIN wishlist w on p.id = w.product_id LEFT JOIN order_items oi ON p.id = oi.product_id LEFT JOIN order_items op ON p.id = op.parent_id WHERE w.id IS NULL AND oi.id IS NULL AND op.id IS NULL;"
|
||||
qb := "DELETE p FROM products p LEFT JOIN order_items oi ON p.id = oi.product_id LEFT JOIN order_items op ON p.id = op.parent_id WHERE oi.id IS NULL AND op.id IS NULL;"
|
||||
return db.WithContext(ctx).Exec(qb).Error
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue