Bugfix update-only-guid and refactor global un-unified access
This commit is contained in:
parent
f1276154ac
commit
2173d6f7fa
1 changed files with 9 additions and 8 deletions
|
@ -13,11 +13,11 @@
|
|||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
(ns rss-thread-watch.feed-generator
|
||||
"Generates feed for requests"
|
||||
"Generates feeds for requests"
|
||||
(:require [ring.middleware.params :as rp]
|
||||
[clj-rss.core :as rss]
|
||||
[clojure.string :as s]
|
||||
[rss-thread-watch.watcher :as cache])
|
||||
[rss-thread-watch.watcher :as watcher])
|
||||
(:gen-class))
|
||||
|
||||
|
||||
|
@ -45,18 +45,18 @@
|
|||
[thread]
|
||||
(assoc thread :guid (format "%d-%.2f"
|
||||
(:no thread)
|
||||
:chod thread)))
|
||||
(:chod thread))))
|
||||
|
||||
(defn filter-chod-posts
|
||||
"Return list of all threads with equal or higher ChoD than requested"
|
||||
[query-vec chod-treshold repeat?]
|
||||
[query-vec chod-treshold repeat? cache]
|
||||
(let [time-of-generation (System/currentTimeMillis)
|
||||
guid-fn (if repeat? (fn [x] (new-guid-always x time-of-generation))
|
||||
update-only-guid)
|
||||
cache-start-index (first (indices (fn [x] (>= (:chod x) chod-treshold))
|
||||
@cache/chod-threads-cache))
|
||||
cache))
|
||||
;; So we don't have to search thru everything we have cached
|
||||
needed-cache-part (subvec @cache/chod-threads-cache cache-start-index) ;Todo: remove that ugly global reference
|
||||
needed-cache-part (subvec cache cache-start-index) ;Todo: remove that ugly global reference
|
||||
actuall-matches (keep (fn [t]
|
||||
(let [title (:title t)]
|
||||
;; Todo: Man, wouldn't it be cool to know which querry matched the thread?
|
||||
|
@ -82,8 +82,9 @@
|
|||
:guid (:guid t)}))
|
||||
|
||||
(defn generate-feed
|
||||
[query-vec chod-treshold repeat?]
|
||||
(let [items (filter-chod-posts query-vec chod-treshold repeat?)
|
||||
"Generates feed from matching items"
|
||||
[query-vec chod-treshold repeat? cache]
|
||||
(let [items (filter-chod-posts query-vec chod-treshold repeat? cache)
|
||||
head {:title "RSS Thread watcher v0.1"
|
||||
:link "https://tools.treebrary.org/thread-watcher/feed.xml"
|
||||
:feed-url "https://tools.treebrary.org/thread-watcher/feed.xml"
|
||||
|
|
Loading…
Reference in a new issue