From c9e1e5522cfaa9a9fc4a7074902ddadbcef26c52 Mon Sep 17 00:00:00 2001 From: horus Date: Mon, 12 Feb 2018 23:46:59 +0100 Subject: Bugfix. (crawler) --- crawler/database.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crawler/database.go') diff --git a/crawler/database.go b/crawler/database.go index a94e2f0..4245c4e 100644 --- a/crawler/database.go +++ b/crawler/database.go @@ -48,12 +48,12 @@ func (app *App) createTables() error { for _, v := range views { var spirit_type string - if v == "misc" { - spirit_type = `spirit_type = "` + v + `"` + if v != "misc" { + spirit_type = `spirit_type = "` + v + `" AND` } else if v == "all" { spirit_type = "" } else { - spirit_type = `spirit_type NOT IN ("` + strings.Join(views, `", "`) + `")` + spirit_type = `spirit_type NOT IN ("` + strings.Join(views, `", "`) + `") AND` } view_query := `CREATE OR REPLACE VIEW ` + v + `_view AS @@ -62,8 +62,8 @@ func (app *App) createTables() error { shop.name as shop, shop.url as shop_url, shop.shipping_costs/100 as shipping_costs, shop.free_shipping, ROUND(100-((discounted_price/original_price)*100)) AS procent, spirit_type, created_at FROM angebot JOIN shop ON angebot.shop = shop.id - WHERE 1 = 1 - ` + spirit_type + ` AND (valid_until IS NULL OR valid_until > (SELECT UNIX_TIMESTAMP()))` + WHERE + ` + spirit_type + ` (valid_until IS NULL OR valid_until > (SELECT UNIX_TIMESTAMP()))` _, err = app.DB.Exec(view_query) if err != nil { return err -- cgit v1.2.3