also flatten tags to be a list of strings
This commit is contained in:
		
							parent
							
								
									431549dbe5
								
							
						
					
					
						commit
						d20eea8691
					
				|  | @ -46,17 +46,24 @@ | |||
|                    "&detail=" detail)] | ||||
|      link))) | ||||
| 
 | ||||
| (defn flatten-tags | ||||
|   [entry] | ||||
|   (let [tags (get entry :tags) | ||||
|         labels (mapv #(get % :label) tags)] | ||||
|     (assoc entry :tags labels))) | ||||
| 
 | ||||
| (defn select-useful-keys | ||||
|   "Given a list of *entries* filter out all the garbage keys" | ||||
|   [entries] | ||||
|   (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 | ||||
|   [annotations] | ||||
|   (-> (mapv #(flatten (seq  %)) annotations) | ||||
|       (flatten) | ||||
|       (->>  (filter #(not (keyword? %)))) | ||||
|   (-> (mapv #(flatten (seq  %)) annotations) ; flatten the nested maps into nested lists | ||||
|       (flatten) ; flatten the nested lists into one big list | ||||
|       (->> (filter #(not (keyword? %)))) ; we only want strings | ||||
|       (vec))) | ||||
| 
 | ||||
| (defn select-useful-annotation-keys | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue