summaryrefslogtreecommitdiff
path: root/crawler/database.go
diff options
context:
space:
mode:
authorhorus2018-02-14 18:32:43 +0100
committerhorus2018-02-14 18:32:43 +0100
commit8499fb035cb2b0d2cb28bf3a48483761f95c1937 (patch)
treea38bb5b3edac67a4d385e88ccfbe0fc64bed7c42 /crawler/database.go
parent62174f7c84a6224a50b43438ce09b461233f7d8e (diff)
downloadalkobote-8499fb035cb2b0d2cb28bf3a48483761f95c1937.tar.gz
Adds URL shorting with polr. (crawler)
Diffstat (limited to 'crawler/database.go')
-rw-r--r--crawler/database.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/crawler/database.go b/crawler/database.go
index 278d891..d0bd632 100644
--- a/crawler/database.go
+++ b/crawler/database.go
@@ -58,7 +58,7 @@ func (app *App) createTables() error {
view_query := `CREATE OR REPLACE VIEW ` + v + `_view AS
SELECT
- angebot.id, angebot.name, angebot.abv, angebot.volume, angebot.url,original_price/100 as original_price, discounted_price/100 as discounted_price, angebot.base_price/100 as base_price, image_url,
+ angebot.id, angebot.name, angebot.abv, angebot.volume, angebot.url as long_url, angebot.short_url as url,original_price/100 as original_price, discounted_price/100 as discounted_price, angebot.base_price/100 as base_price, image_url,
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
@@ -116,7 +116,7 @@ func (app *App) save_offer(W []Angebot) error {
func (app *App) remove_expired(W []Angebot, shop_id int) error {
- query := `SELECT id, shop, name, url, original_price, discounted_price FROM angebot WHERE shop = ? AND created_at < ? AND valid_until IS NULL`
+ query := `SELECT id, shop, name, url, original_price, discounted_price FROM all_view WHERE shop = ? AND created_at < ?`
rows, err := app.DB.Queryx(query, shop_id, app.Now)
if err != nil {