finished POC for filtering by favorited replies

master
bom 2 years ago
parent ec73ff83e3
commit 44177d5c0b

@ -59,13 +59,30 @@
first))) first)))
out)) out))
(defn favorited-replies? [host-url reply-id account-name] (defn favorited-replies? [host-url account-name reply-id]
(go (let [out (chan)]
(infra/debug (->> (go
(<p! (api/get-favorited-by host-url reply-id)) (>! out
api/mastojs->edn (->>
(filter #(= account-name (:acct %))) (<p! (api/get-favorited-by host-url reply-id))
(infra/debug))))) api/mastojs->edn
(filter #(= account-name (:acct %)))
(empty?)
(not))))
out))
(defn favorited? [host-url account-name replies]
(let [out (chan)]
(go
(>! out
(loop [loc-replies replies
result []]
(if (empty? loc-replies)
result
(recur (rest loc-replies)
(conj result (<! (favorited-replies? host-url account-name (first loc-replies)))))))))
out))
(defn init [] (defn init []
(go (go
@ -78,26 +95,20 @@
(<p! (api/get-account-statuses host-url account-id)) (<p! (api/get-account-statuses host-url account-id))
api/mastojs->edn) api/mastojs->edn)
test-status (-> test-status (->
(<p! (api/get-favorited-by host-url "107779739758156958")) (<p! (api/get-replies host-url "107779492679907372"))
api/mastojs->edn) api/mastojs->edn)
filtered (filter (favorited-replies? host-url "107779739758156958" "bastian@digitalcourage.social") (:descendants test-status)) favorited (<! (favorited? host-url "bastian@digitalcourage.social" (map :id (:descendants test-status))))
combined (map (fn [s f] {:status s :favorited f}) (:descendants test-status) favorited)
filtered (map :status (filter :favorited combined))
] ]
;"107779739758156958"
;(->> statuus ;(->> statuus
; (take 4) ; (take 4)
; (rb/masto->html) ; (rb/masto->html)
; (render-html) ; (render-html)
; (render-to-document)) ; (render-to-document))
;(go (infra/debug (<! (favorited-replies? host-url "107779739758156958" "team@meissa.social")))) (->> filtered
;(go (let [test (api/mastojs->edn (<p! (api/get-favorited-by host-url "107779739758156958")))] (infra/debug)
; (infra/debug (filter #(= "team@meissa.social" (:acct %)) test)))) (rb/masto->html)
(infra/debug test-status) (render-html)
(infra/debug filtered) (render-to-document))
;(->> filtered )))
; (infra/debug)
; (rb/masto->html)
; (render-html)
; (render-to-document))
)))
Loading…
Cancel
Save