This commit is contained in:
merdan 2022-09-01 16:26:15 +05:00
parent 8cf3adbf74
commit 8deac3d76d
1 changed files with 10 additions and 1 deletions

View File

@ -66,6 +66,13 @@ func Start(w http.ResponseWriter, route *http.Request) {
mainImportWG.Add(len(mainCategories))
errDel := deleteProducts()
if errDel != nil {
http.Error(w, errDel.Error(), http.StatusInternalServerError)
return
}
for _, element := range mainCategories {
slug := element.Translations[0].Slug
@ -81,12 +88,14 @@ func Start(w http.ResponseWriter, route *http.Request) {
}
func deleteProducts() {
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) {