Temporary stubs
This commit is contained in:
parent
f0c8b6479b
commit
0d3af72b6b
14
scrape.go
14
scrape.go
@ -100,6 +100,10 @@ func processData(restaurants []restaurant, stationsPath string) error {
|
|||||||
return nil
|
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 {
|
func dumpData(dbPath string, restaraunts []restaurant) error {
|
||||||
db, err := sql.Open("sqlite3", dbPath)
|
db, err := sql.Open("sqlite3", dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -133,6 +137,8 @@ func dumpData(dbPath string, restaraunts []restaurant) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range restaraunts {
|
for _, r := range restaraunts {
|
||||||
|
delicious, accommodating, affordable, atmospheric := buildFeatures(r)
|
||||||
|
|
||||||
_, err = db.Exec(`
|
_, err = db.Exec(`
|
||||||
INSERT INTO reviews(
|
INSERT INTO reviews(
|
||||||
name,
|
name,
|
||||||
@ -149,10 +155,10 @@ func dumpData(dbPath string, restaraunts []restaurant) error {
|
|||||||
) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||||
r.name,
|
r.name,
|
||||||
r.url,
|
r.url,
|
||||||
0,
|
delicious,
|
||||||
0,
|
accommodating,
|
||||||
0,
|
affordable,
|
||||||
0,
|
atmospheric,
|
||||||
r.longitude,
|
r.longitude,
|
||||||
r.latitude,
|
r.latitude,
|
||||||
r.closestStnDist,
|
r.closestStnDist,
|
||||||
|
Loading…
Reference in New Issue
Block a user