summaryrefslogtreecommitdiff
path: root/fetcher.fnl
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-10-10 11:51:21 +0600
committerunwox <me@unwox.com>2024-10-10 11:51:38 +0600
commitdfcdaab3a84389e610a57fa82ee0d3a216f4821d (patch)
treee0318abc43baaf83987381312a02c97ffe8b6f9b /fetcher.fnl
parentddc11ff1cc31f17ff46523a649917940357825b5 (diff)
allow to specify several tags for a product (instead of one category)
Diffstat (limited to 'fetcher.fnl')
-rw-r--r--fetcher.fnl18
1 files changed, 9 insertions, 9 deletions
diff --git a/fetcher.fnl b/fetcher.fnl
index bf22abf..6a133f0 100644
--- a/fetcher.fnl
+++ b/fetcher.fnl
@@ -49,25 +49,25 @@
(gather 1 []))
-(fn categorize-many [items category]
+(fn categorize-many [items tags]
(map
(fn [_ item]
- (tset item :category
- (if category
- category
- (parser.guess-category item.title)))
+ (tset item :tags
+ (-> (or tags [])
+ (array.concat (parser.guess-tags item.title))
+ (array.unique)))
item)
items))
(fn from-html [categories url-formatter item-peg normalizer]
(reduce
- (fn [_ {: category : path} result]
+ (fn [_ {: tags : path} result]
(array.concat
result
(categorize-many
(map #(normalizer $2)
(walk-html-pages url-formatter path item-peg))
- category)))
+ tags)))
categories
[]))
@@ -98,13 +98,13 @@
(fn from-json [categories url-formatter response-destructor normalizer]
(reduce
- (fn [_ {: category : path} result]
+ (fn [_ {: tags : path} result]
(array.concat
result
(categorize-many
(map #(normalizer $2)
(walk-json-pages url-formatter path response-destructor))
- category)))
+ tags)))
categories
[]))