diff --git a/README.org b/README.org index 7412302..df34812 100644 --- a/README.org +++ b/README.org @@ -24,13 +24,13 @@ Right now there is no automated way to generate your feed url but making one by **** URL parameters -| Param name | Default value | Can have multiple? | Mandatory? | Short description | -|------------+---------------+--------------------+----------------------+--------------------------------------------------------------------------------------------------| -| board | "mlp" | No | No (not implemented) | Which board to generate feed for, *ONLY* ​/mlp​/ is supported | -| q | nil | Yes | Yes (1 or more) | This string is used to filter threads according to their titles | -| chod | 94 | No | No | CHanceOfDeath - will include thread in the feed if it's chance to death i > chod | -| repeat | ~false~ | No | No | Whether to make new notification on every server update even when thread doesnt have higher chod | -| recreate | ~bool~ | Not implemented | Not implemented | Whether to notify when creation of new thread matching querry is detected (uses 4chans RSS) | +| Param name | Values [default] | Can have multiple? | Mandatory? | Short description | +|------------+-------------------------+--------------------+-------------------------+--------------------------------------------------------------------------------------------------| +| board | "mlp" | No | No (not implemented) | Which board to generate feed for, *ONLY* ​/mlp​/ is supported | +| q | nil | Yes | Yes (1 or more) | This string is used to filter threads according to their titles | +| chod | 60-99 [94] | No | No | CHanceOfDeath - will include thread in the feed if it's chance to death i > chod | +| repeat | true, paranoid, [false] | No | No (partly implemented) | Whether to make new notification on every server update even when thread doesnt have higher chod | +| recreate | ~bool~ | Not implemented | Not implemented | Whether to notify when creation of new thread matching querry is detected (uses 4chans RSS) | **** How to create URL diff --git a/src/rss_thread_watch/feed_generator.clj b/src/rss_thread_watch/feed_generator.clj index df028c6..2ec8388 100644 --- a/src/rss_thread_watch/feed_generator.clj +++ b/src/rss_thread_watch/feed_generator.clj @@ -49,15 +49,17 @@ (:chod thread)))) (defn filter-chod-posts - "Return list of all threads with equal or higher ChoD than requested" + "Return list of all threads with equal or higher ChoD than requested + + READS FROM GLOBALS: watcher.time-of-cache" ;Todo: best thing would be to add timestamp to cache [query-vec chod-treshold repeat? cache] - (let [time-of-generation (System/currentTimeMillis) + (let [time-of-generation @watcher/time-of-cache 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)) ;; So we don't have to search thru everything we have cached - needed-cache-part (subvec cache cache-start-index) ;Todo: remove that ugly global reference + needed-cache-part (subvec cache cache-start-index) actuall-matches (keep (fn [t] (let [title (:title t)] ;; Todo: Man, wouldn't it be cool to know which querry matched the thread? diff --git a/src/rss_thread_watch/watcher.clj b/src/rss_thread_watch/watcher.clj index 0e1b841..eaf2df8 100644 --- a/src/rss_thread_watch/watcher.clj +++ b/src/rss_thread_watch/watcher.clj @@ -22,6 +22,8 @@ "Cached vector of threads that have CHanceOfDeath > configured" (atom [])) +(def time-of-cache (atom 0)) + (defn process-page "Procesess every thread in page, leaving only relevant information (title no chod)" @@ -64,4 +66,5 @@ threads-total (+ (* threads-per-page (dec pages-total)) (count (:threads (last catalog)))) ;; Todo: Yeah, maybe this calculation could be refactored into let to-index (filter (fn [item] (<= starting-page (:page item))) catalog)] - (reset! chod-threads-cache (build-cache to-index pages-total threads-per-page threads-total)))) + (reset! chod-threads-cache (build-cache to-index pages-total threads-per-page threads-total)) + (reset! time-of-cache (System/currentTimeMillis))))