From 178f2c46167bd3128e130a19fb7d5b946a317943 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 23 Aug 2015 17:03:30 +0900 Subject: [PATCH] Cleanup --- scrape.go | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/scrape.go b/scrape.go index 4dd27a4..18ca644 100644 --- a/scrape.go +++ b/scrape.go @@ -32,7 +32,7 @@ import ( _ "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) if err != nil { return nil, err @@ -78,7 +78,7 @@ func scrapeData(urlsPath, geocachePath, webcachePath string) ([]restaurant, erro return nil, err } - restaurants, err := scrapeUrls(urlsPath, wc, gc) + restaurants, err := scrapeDataUrls(urlsPath, wc, gc) if err != nil { return nil, err } @@ -86,7 +86,7 @@ func scrapeData(urlsPath, geocachePath, webcachePath string) ([]restaurant, erro return restaurants, nil } -func processData(restaurants []restaurant, stationsPath string) error { +func computeStnData(restaurants []restaurant, stationsPath string) error { sq, err := newStationQuery(stationsPath) if err != nil { return err @@ -111,10 +111,6 @@ func dumpData(dbPath string, restaraunts []restaurant) error { } defer db.Close() - // - // Restaurants - // - _, err = db.Exec(` DROP TABLE IF EXISTS reviews; CREATE TABLE reviews( @@ -170,10 +166,6 @@ func dumpData(dbPath string, restaraunts []restaurant) error { } } - // - // Categories - // - _, err = db.Exec(` DROP TABLE IF EXISTS categories; CREATE TABLE categories( @@ -190,10 +182,6 @@ func dumpData(dbPath string, restaraunts []restaurant) error { } } - // - // History - // - _, err = db.Exec(` DROP TABLE IF EXISTS history; CREATE TABLE history( @@ -206,10 +194,6 @@ func dumpData(dbPath string, restaraunts []restaurant) error { return err } - // - // HistoryGroup - // - _, err = db.Exec(` DROP TABLE IF EXISTS historyGroups; CREATE TABLE historyGroups( @@ -232,7 +216,7 @@ func main() { panic(err) } - if err := processData(restaurants, "data/stations.json"); err != nil { + if err := computeStnData(restaurants, "data/stations.json"); err != nil { panic(err) }