diff --git a/scrape.go b/scrape.go index 7b57f5f..4560add 100644 --- a/scrape.go +++ b/scrape.go @@ -100,6 +100,10 @@ func processData(restaurants []restaurant, stationsPath string) error { return nil } +func buildFeatures(r restaurant) (delicious, accommodating, affordable, atmospheric float64) { + return r.features["food"], r.features["service"], r.features["value"], r.features["atmosphere"] +} + func dumpData(dbPath string, restaraunts []restaurant) error { db, err := sql.Open("sqlite3", dbPath) if err != nil { @@ -133,6 +137,8 @@ func dumpData(dbPath string, restaraunts []restaurant) error { } for _, r := range restaraunts { + delicious, accommodating, affordable, atmospheric := buildFeatures(r) + _, err = db.Exec(` INSERT INTO reviews( name, @@ -149,10 +155,10 @@ func dumpData(dbPath string, restaraunts []restaurant) error { ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, r.name, r.url, - 0, - 0, - 0, - 0, + delicious, + accommodating, + affordable, + atmospheric, r.longitude, r.latitude, r.closestStnDist,