summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crawler/convert_price.go2
-rw-r--r--crawler/database.go10
2 files changed, 6 insertions, 6 deletions
diff --git a/crawler/convert_price.go b/crawler/convert_price.go
index 2d2bc1a..f1c88b4 100644
--- a/crawler/convert_price.go
+++ b/crawler/convert_price.go
@@ -30,7 +30,7 @@ func convert_price(price string) (int, error) {
price = strings.TrimSuffix(strings.ToLower(price), "euro")
price = strings.TrimSpace(price)
- r, err := regexp.Compile(`[0-9]+([.,][0-9]+)?`)
+ r, err := regexp.Compile(`([0-9]+[.])?[0-9]+([.,][0-9]+)?`)
if err != nil {
return 0, err
}
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