Cleanup
This commit is contained in:
parent
f25ebfebbd
commit
178f2c4616
24
scrape.go
24
scrape.go
@ -32,7 +32,7 @@ import (
|
|||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func scrapeUrls(filename string, wc *webCache, gc *geoCache) ([]restaurant, error) {
|
func scrapeDataUrls(filename string, wc *webCache, gc *geoCache) ([]restaurant, error) {
|
||||||
file, err := os.Open(filename)
|
file, err := os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -78,7 +78,7 @@ func scrapeData(urlsPath, geocachePath, webcachePath string) ([]restaurant, erro
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
restaurants, err := scrapeUrls(urlsPath, wc, gc)
|
restaurants, err := scrapeDataUrls(urlsPath, wc, gc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ func scrapeData(urlsPath, geocachePath, webcachePath string) ([]restaurant, erro
|
|||||||
return restaurants, nil
|
return restaurants, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func processData(restaurants []restaurant, stationsPath string) error {
|
func computeStnData(restaurants []restaurant, stationsPath string) error {
|
||||||
sq, err := newStationQuery(stationsPath)
|
sq, err := newStationQuery(stationsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -111,10 +111,6 @@ func dumpData(dbPath string, restaraunts []restaurant) error {
|
|||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
//
|
|
||||||
// Restaurants
|
|
||||||
//
|
|
||||||
|
|
||||||
_, err = db.Exec(`
|
_, err = db.Exec(`
|
||||||
DROP TABLE IF EXISTS reviews;
|
DROP TABLE IF EXISTS reviews;
|
||||||
CREATE TABLE reviews(
|
CREATE TABLE reviews(
|
||||||
@ -170,10 +166,6 @@ func dumpData(dbPath string, restaraunts []restaurant) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Categories
|
|
||||||
//
|
|
||||||
|
|
||||||
_, err = db.Exec(`
|
_, err = db.Exec(`
|
||||||
DROP TABLE IF EXISTS categories;
|
DROP TABLE IF EXISTS categories;
|
||||||
CREATE TABLE categories(
|
CREATE TABLE categories(
|
||||||
@ -190,10 +182,6 @@ func dumpData(dbPath string, restaraunts []restaurant) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// History
|
|
||||||
//
|
|
||||||
|
|
||||||
_, err = db.Exec(`
|
_, err = db.Exec(`
|
||||||
DROP TABLE IF EXISTS history;
|
DROP TABLE IF EXISTS history;
|
||||||
CREATE TABLE history(
|
CREATE TABLE history(
|
||||||
@ -206,10 +194,6 @@ func dumpData(dbPath string, restaraunts []restaurant) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// HistoryGroup
|
|
||||||
//
|
|
||||||
|
|
||||||
_, err = db.Exec(`
|
_, err = db.Exec(`
|
||||||
DROP TABLE IF EXISTS historyGroups;
|
DROP TABLE IF EXISTS historyGroups;
|
||||||
CREATE TABLE historyGroups(
|
CREATE TABLE historyGroups(
|
||||||
@ -232,7 +216,7 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := processData(restaurants, "data/stations.json"); err != nil {
|
if err := computeStnData(restaurants, "data/stations.json"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user