also flatten tags to be a list of strings

This commit is contained in:
Anish Lakhwara 2022-09-03 13:22:41 +10:00
parent 431549dbe5
commit d20eea8691

View file

@ -46,17 +46,24 @@
"&detail=" detail)] "&detail=" detail)]
link))) link)))
(defn flatten-tags
[entry]
(let [tags (get entry :tags)
labels (mapv #(get % :label) tags)]
(assoc entry :tags labels)))
(defn select-useful-keys (defn select-useful-keys
"Given a list of *entries* filter out all the garbage keys" "Given a list of *entries* filter out all the garbage keys"
[entries] [entries]
(let [useful-keys [:tags :title :url :annotations :id]] (let [useful-keys [:tags :title :url :annotations :id]]
(mapv #(select-keys % useful-keys) entries))) (->> (mapv #(select-keys % useful-keys) entries)
(mapv #(flatten-tags %)))))
(defn flatten-annotation (defn flatten-annotation
[annotations] [annotations]
(-> (mapv #(flatten (seq %)) annotations) (-> (mapv #(flatten (seq %)) annotations) ; flatten the nested maps into nested lists
(flatten) (flatten) ; flatten the nested lists into one big list
(->> (filter #(not (keyword? %)))) (->> (filter #(not (keyword? %)))) ; we only want strings
(vec))) (vec)))
(defn select-useful-annotation-keys (defn select-useful-annotation-keys