summaryrefslogtreecommitdiff
path: root/crawler/database.go
diff options
context:
space:
mode:
authorMax2018-02-08 18:26:41 +0100
committerMax2018-02-08 18:26:41 +0100
commitf6904aab20e2d09255fd0adabfd246165ff3cb02 (patch)
treef7ac27cb5dd34443640235a97ce9bde8f2a1816a /crawler/database.go
parentae7ed42df6a55e36c82b88e7c71569951847a68c (diff)
downloadalkobote-f6904aab20e2d09255fd0adabfd246165ff3cb02.tar.gz
Crawler extracts volume, price per litre and abv. (MC Whisky, Rum & Co, Whic)
Diffstat (limited to 'crawler/database.go')
-rw-r--r--crawler/database.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/crawler/database.go b/crawler/database.go
index b1d4e5e..085f210 100644
--- a/crawler/database.go
+++ b/crawler/database.go
@@ -29,7 +29,7 @@ func (app *App) createTables() error {
volume FLOAT,
original_price INT,
discounted_price INT,
- price_per_litre INT,
+ base_price INT,
image_url TEXT,
spirit_type TEXT,
valid_until INT DEFAULT NULL,
@@ -43,7 +43,7 @@ func (app *App) createTables() error {
query3 := `CREATE OR REPLACE VIEW whisky_view AS
SELECT
- angebot.id, angebot.name, angebot.abv, angebot.volume, angebot.url,original_price, discounted_price, angebot.price_per_litre, image_url,
+ angebot.id, angebot.name, angebot.abv, angebot.volume, angebot.url,original_price, discounted_price, angebot.base_price, image_url,
shop.name as shop, shop.url as shop_url, (original_price/discounted_price) AS quotient
FROM angebot
JOIN shop ON angebot.shop = shop.id
@@ -56,7 +56,7 @@ func (app *App) createTables() error {
func (app *App) save_offer(W []Angebot) error {
- query := `INSERT INTO angebot (shop, name, url, abv, volume, original_price, discounted_price, price_per_litre, valid_until, image_url, spirit_type, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
+ query := `INSERT INTO angebot (shop, name, url, abv, volume, original_price, discounted_price, base_price, valid_until, image_url, spirit_type, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
stmt, err := app.DB.Prepare(query)
if err != nil {
@@ -80,9 +80,9 @@ func (app *App) save_offer(W []Angebot) error {
if err == sql.ErrNoRows {
if 0 == o.Valid_until {
- _, err = stmt.Exec(o.Shop, o.Name, o.Url, o.Abv, o.Volume, o.Original_price, o.Discounted_price, o.Price_per_litre, sql.NullInt64{}, o.Image_url, o.Spirit_type, app.Now)
+ _, err = stmt.Exec(o.Shop, o.Name, o.Url, o.Abv, o.Volume, o.Original_price, o.Discounted_price, o.Base_price, sql.NullInt64{}, o.Image_url, o.Spirit_type, app.Now)
} else {
- _, err = stmt.Exec(o.Shop, o.Name, o.Url, o.Abv, o.Volume, o.Original_price, o.Discounted_price, o.Price_per_litre, o.Valid_until, o.Image_url, o.Spirit_type, app.Now)
+ _, err = stmt.Exec(o.Shop, o.Name, o.Url, o.Abv, o.Volume, o.Original_price, o.Discounted_price, o.Base_price, o.Valid_until, o.Image_url, o.Spirit_type, app.Now)
}
if err != nil {
return err