diff options
| author | horus | 2018-02-19 21:43:54 +0100 |
|---|---|---|
| committer | horus | 2018-02-19 21:43:54 +0100 |
| commit | dd48edbc9834eef46b6590439a61c7fa0242c8db (patch) | |
| tree | 5af98d7ec7de633c97024756c13fa9bad0bd7436 /crawler/shops.go | |
| parent | c2bf9dc1d1cccc2d4cf7a1a2e1ce15eea7da6624 (diff) | |
| download | alkobote-dd48edbc9834eef46b6590439a61c7fa0242c8db.tar.gz | |
Adds config option to crawl only specific shops. (crawler)
Diffstat (limited to 'crawler/shops.go')
| -rw-r--r-- | crawler/shops.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crawler/shops.go b/crawler/shops.go index 1babc9d..be9bd53 100644 --- a/crawler/shops.go +++ b/crawler/shops.go @@ -1,6 +1,8 @@ package main import ( + "strings" + log "github.com/Sirupsen/logrus" ) @@ -96,7 +98,15 @@ func (app *App) getShops() ([]Shop, error) { Shops := []Shop{} - query := `SELECT id,name,short_url,url,logo_url,shipping_costs,free_shipping FROM shop` + var shop_query string + if len(app.Config.ShopIDs) > 0 { + shopIDs := strings.Join(app.Config.ShopIDs, `", "`) + if shopIDs != "" { + shop_query = " WHERE id IN (" + shopIDs + ")" + } + + } + query := `SELECT id,name,short_url,url,logo_url,shipping_costs,free_shipping FROM shop ` + shop_query rows, err := app.DB.Queryx(query) if err != nil { |
