Merge pull request 'Implement repeat=paranoid' (#28) from hotfix-repeat into stable
Reviewed-on: https://git.treebrary.org/Treebrary.org/rss-thread-watcher/pulls/28
This commit is contained in:
commit
99d01b3f70
3 changed files with 20 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
|||
(defproject rss-thread-watch "0.4.0-SNAPSHOT"
|
||||
(defproject rss-thread-watch "0.4.1-SNAPSHOT"
|
||||
:description "RSS based thread watcher"
|
||||
:url "http://example.com/FIXME"
|
||||
:license {:name "AGPL-3.0-only"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
[rss-thread-watch.utils :as u])
|
||||
(:gen-class))
|
||||
|
||||
(def VERSION "0.4.0")
|
||||
(def VERSION "0.4.1")
|
||||
|
||||
;; Internal default config
|
||||
(def CONFIG-DEFAULT
|
||||
|
|
|
@ -36,6 +36,15 @@
|
|||
"-"
|
||||
time)))
|
||||
|
||||
(defn new-guid-paranoid
|
||||
"Generate unique GUID on EVERY request to the feed.
|
||||
|
||||
Usefull for when you really don't want thread to die.
|
||||
By making new GUID on every request you can be sure that what you're
|
||||
seeing in your feed reader isn't cached"
|
||||
[thread]
|
||||
(new-guid-always thread (System/currentTimeMillis)))
|
||||
|
||||
(defn update-only-guid
|
||||
"Generates new GUID for feed item ONLY if the threads ChoD increased
|
||||
|
||||
|
@ -53,8 +62,10 @@
|
|||
|
||||
(let [{time-of-generation :time
|
||||
cache :data} board-cache
|
||||
guid-fn (if repeat? (fn [x] (new-guid-always x time-of-generation))
|
||||
update-only-guid)
|
||||
guid-fn (case repeat?
|
||||
"paranoid" new-guid-paranoid
|
||||
"true" (fn [x] (new-guid-always x time-of-generation))
|
||||
update-only-guid)
|
||||
cache-start-index (first (ut/indices (fn [x] (>= (:chod x) chod-treshold))
|
||||
cache))
|
||||
;; So we don't have to search thru everything we have cached
|
||||
|
@ -87,7 +98,7 @@
|
|||
"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.4" ;TODO: hardcoded string here, remake to reference to config.clj
|
||||
head {:title "RSS Thread watcher v0.4.1" ;TODO: hardcoded string here, remake to reference to config.clj
|
||||
:link "https://tools.treebrary.org/thread-watcher/feed.xml"
|
||||
:feed-url "https://tools.treebrary.org/thread-watcher/feed.xml"
|
||||
:description "RSS based thread watcher"}
|
||||
|
@ -102,13 +113,14 @@
|
|||
rss-thread-watch.watcher.GLOBAL-CONFIG" ;TODO: Update if it really reads from there anymore
|
||||
[rqst]
|
||||
(try (let [{{chod "chod"
|
||||
board "board" :or {chod "94"
|
||||
board (get @watcher/GLOBAL-CONFIG :default-board)}
|
||||
board "board"
|
||||
repeat? "repeat" :or {chod "94"
|
||||
board (get @watcher/GLOBAL-CONFIG :default-board)
|
||||
repeat? false}
|
||||
:as prms} :params
|
||||
uri :uri} rqst
|
||||
qrs (prms "q")
|
||||
queries (if (vector? qrs) qrs [qrs]) ; to always return vector
|
||||
repeat? (prms "repeat")
|
||||
real-chod (if-let [ch (or (and (vector? chod)
|
||||
(first chod))
|
||||
chod)]
|
||||
|
|
Loading…
Reference in a new issue