From dd48edbc9834eef46b6590439a61c7fa0242c8db Mon Sep 17 00:00:00 2001 From: horus Date: Mon, 19 Feb 2018 21:43:54 +0100 Subject: Adds config option to crawl only specific shops. (crawler) --- crawler/shops.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crawler/shops.go') 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 { -- cgit v1.2.3