desc fx8
This commit is contained in:
parent
8deac3d76d
commit
8b42aa0503
|
|
@ -66,7 +66,7 @@ func Start(w http.ResponseWriter, route *http.Request) {
|
|||
|
||||
mainImportWG.Add(len(mainCategories))
|
||||
|
||||
errDel := deleteProducts()
|
||||
errDel := gm.DeleteProducts(baza)
|
||||
|
||||
if errDel != nil {
|
||||
http.Error(w, errDel.Error(), http.StatusInternalServerError)
|
||||
|
|
@ -88,16 +88,6 @@ func Start(w http.ResponseWriter, route *http.Request) {
|
|||
|
||||
}
|
||||
|
||||
func deleteProducts() error {
|
||||
//todo delete non ordered & non favorited products
|
||||
//select distinct ordered and favorited product ids
|
||||
//todo delete from elastico
|
||||
//Delete from products where id in (select distinct)
|
||||
|
||||
return baza.Delete(&gm.Product{}).Error
|
||||
|
||||
}
|
||||
|
||||
func startImport(dbName string, db *gorm.DB) {
|
||||
defer mainImportWG.Done()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package gorm_models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Product struct {
|
||||
ID uint `gorm:"primary_key"`
|
||||
|
|
@ -86,3 +89,14 @@ type Tabler interface {
|
|||
func (ProductFlat) TableName() string {
|
||||
return "product_flat"
|
||||
}
|
||||
|
||||
func DeleteProducts(db *gorm.DB) error {
|
||||
//todo delete non ordered & non favorited products
|
||||
//select distinct ordered and favorited product ids
|
||||
//todo delete from elastico
|
||||
//Delete from products where id in (select distinct)
|
||||
//db.Exec("DELETE FROM products")
|
||||
|
||||
return db.Exec("DELETE FROM products").Error
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue