test real baza

This commit is contained in:
merdan 2023-05-03 15:18:01 +05:00
parent 73941daf44
commit e8910eca48
1 changed files with 13 additions and 7 deletions

20
main.go
View File

@ -71,8 +71,8 @@ func main() {
func worker(db *gorm.DB, stopCh <-chan struct{}, updatePeriod time.Duration) { func worker(db *gorm.DB, stopCh <-chan struct{}, updatePeriod time.Duration) {
importer, _ := repositories.ParseImporterInstance(db) importer, _ := repositories.ParseImporterInstance(db)
ticker := time.NewTicker(time.Second)
ticker = time.NewTicker(updatePeriod) ticker := time.NewTicker(updatePeriod)
defer ticker.Stop() defer ticker.Stop()
log.Printf("Updater worker Started") log.Printf("Updater worker Started")
@ -88,7 +88,7 @@ func worker(db *gorm.DB, stopCh <-chan struct{}, updatePeriod time.Duration) {
continue continue
} else { } else {
log.Println(len(result)) log.Println(len(result))
continue
} }
// Update products as needed // Update products as needed
@ -105,13 +105,19 @@ func worker(db *gorm.DB, stopCh <-chan struct{}, updatePeriod time.Duration) {
jsonProduct, err := parser.GetProductDetailWithOptions(data.ID, data.ProductGroupID) jsonProduct, err := parser.GetProductDetailWithOptions(data.ID, data.ProductGroupID)
// Update the product in the database if err != nil {
if err := importer.UpdateOrCreate(jsonProduct).Error; err != nil { log.Println("Error getting product information:", err)
log.Println("Error decoding product information:", err)
continue continue
} }
log.Printf("Product %d updated: %+v\n", product.ID, product) log.Printf("Product %d updated: %+v\n", product.ID, jsonProduct)
// Update the product in the database
//if err := importer.UpdateOrCreate(jsonProduct).Error; err != nil {
// log.Println("Error decoding product information:", err)
// continue
//}
//
//log.Printf("Product %d updated: %+v\n", product.ID, product)
} }
} }
} }