wallabag now has functions to filter down to annotated & archived

entries, and filters annotations to only have the quote in the map
This commit is contained in:
Anish Lakhwara 2022-09-03 13:05:46 +10:00
parent 3a18591f02
commit 32a7a6750f

View file

@ -24,7 +24,6 @@
; Setup Token as an atom for use later on ; Setup Token as an atom for use later on
(def token (atom 1)) (def token (atom 1))
(reset! token (generate-token)) (reset! token (generate-token))
(defn make-request (defn make-request
@ -53,6 +52,15 @@
(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)))
(defn select-useful-annotation-keys
[entry]
(let [only-useful-annotations (mapv #(select-keys % [:quote]) (get entry :annotations))]
(assoc entry :annotations only-useful-annotations)))
(defn map-useful-annotation-keys
[entries]
(mapv select-useful-annotation-keys entries))
(defn make-wallabag-link (defn make-wallabag-link
"Given a single entry turn the :id key into a hardcoded mossnet wallabag clickable link" "Given a single entry turn the :id key into a hardcoded mossnet wallabag clickable link"
[entry] [entry]
@ -116,17 +124,27 @@
acc-new acc-new
(get-all-entries last-link acc)))))) (get-all-entries last-link acc))))))
(defn get-all-archived-entries (defn get-archived-entries
"Returns a filtered list of all archived entries" "Returns a filtered list of all archived entries"
[] []
(get-all-entries {:per-page 20 :archive 1 :detail "metadata"})) (get-all-entries {:per-page 20 :archive 1 :detail "metadata"}))
(get-all-archived-entries) (defn get-archived-annotated-entries
"Return archived entries that have an annotation"
[]
(let [archived-entries (get-archived-entries)]
(-> (filterv (fn [entry]
(let [annotations (get entry :annotations)]
(> (count annotations) 0)))
archived-entries)
(map-useful-annotation-keys))))
(get-archived-annotated-entries)
(comment (comment
(-> (make-request (build-link) (get @token :access_token)) (-> (make-request (build-link) (get @token :access_token))
(make-resp-to-entries)) (make-resp-to-entries))
(count (get-all-archived-entries)) (count (get-archived-entries))
(def next-link (atom "")) (def next-link (atom ""))
; Repeatedly get next link until it's not there anymore ; Repeatedly get next link until it's not there anymore
(let [link (build-link 1 20 1 "metadata") (let [link (build-link 1 20 1 "metadata")