From dfcdaab3a84389e610a57fa82ee0d3a216f4821d Mon Sep 17 00:00:00 2001 From: unwox Date: Thu, 10 Oct 2024 11:51:21 +0600 Subject: allow to specify several tags for a product (instead of one category) --- fetcher.fnl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'fetcher.fnl') 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 [])) -- cgit v1.2.3