fix sql
This commit is contained in:
parent
feb10c15ef
commit
22f275fb03
|
|
@ -140,8 +140,8 @@ func GetWishlistProducts(db *gorm.DB) ([]Product, error) {
|
|||
func GetFlatSources(db *gorm.DB) ([]ProductAttributeValue, error) {
|
||||
var productSources []ProductAttributeValue
|
||||
err := db.Joins("JOIN wishlist wp ON product_attribute_values.product_id = wp.product_id").
|
||||
Joins("JOIN marketplace_products mp ON product_attribute_values.product_id = mp.product_id where marketplace_seller_id=1").
|
||||
Find(&productSources, "text_value IS NOT NULL AND attribute_id=31").Error
|
||||
Joins("JOIN marketplace_products mp ON product_attribute_values.product_id = mp.product_id").
|
||||
Find(&productSources, "mp.marketplace_seller_id=1 AND product_attribute_values.text_value IS NOT NULL AND product_attribute_values.attribute_id=31").Error
|
||||
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
|
|
|
|||
12
main.go
12
main.go
|
|
@ -40,7 +40,6 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalf("Error connecting to database: %s", err)
|
||||
}
|
||||
importer, _ := repositories.ParseImporterInstance(db)
|
||||
|
||||
updatePeriodStr := os.Getenv("UPDATE_PERIOD")
|
||||
updatePeriod, err := time.ParseDuration(updatePeriodStr)
|
||||
|
|
@ -49,7 +48,7 @@ func main() {
|
|||
}
|
||||
// Start the worker
|
||||
stopCh := make(chan struct{})
|
||||
go worker(importer, stopCh, updatePeriod)
|
||||
go worker(db, stopCh, updatePeriod)
|
||||
|
||||
// Wait for termination signal
|
||||
signalCh := make(chan os.Signal, 1)
|
||||
|
|
@ -70,10 +69,13 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func worker(importer *repositories.Importer, stopCh <-chan struct{}, updatePeriod time.Duration) {
|
||||
ticker := time.NewTicker(updatePeriod)
|
||||
func worker(db *gorm.DB, stopCh <-chan struct{}, updatePeriod time.Duration) {
|
||||
importer, _ := repositories.ParseImporterInstance(db)
|
||||
ticker := time.NewTicker(time.Second)
|
||||
ticker = time.NewTicker(updatePeriod)
|
||||
defer ticker.Stop()
|
||||
log.Printf("Updater worker Started")
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-stopCh:
|
||||
|
|
@ -85,7 +87,7 @@ func worker(importer *repositories.Importer, stopCh <-chan struct{}, updatePerio
|
|||
log.Println("Error retrieving products:", err)
|
||||
continue
|
||||
} else {
|
||||
log.Println(len(result))
|
||||
log.Println(result)
|
||||
}
|
||||
|
||||
// Update products as needed
|
||||
|
|
|
|||
Loading…
Reference in New Issue