summaryrefslogtreecommitdiff
path: root/crawler/shops.go
diff options
context:
space:
mode:
authorhorus2018-02-19 21:43:54 +0100
committerhorus2018-02-19 21:43:54 +0100
commitdd48edbc9834eef46b6590439a61c7fa0242c8db (patch)
tree5af98d7ec7de633c97024756c13fa9bad0bd7436 /crawler/shops.go
parentc2bf9dc1d1cccc2d4cf7a1a2e1ce15eea7da6624 (diff)
downloadalkobote-dd48edbc9834eef46b6590439a61c7fa0242c8db.tar.gz
Adds config option to crawl only specific shops. (crawler)
Diffstat (limited to 'crawler/shops.go')
-rw-r--r--crawler/shops.go12
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 {