diff --git a/src/rss_thread_watch/watcher.clj b/src/rss_thread_watch/watcher.clj index 037fc24..e6b33db 100644 --- a/src/rss_thread_watch/watcher.clj +++ b/src/rss_thread_watch/watcher.clj @@ -38,10 +38,7 @@ :chod (* 100 (float (/ index threads-total)))})))))) (defn build-cache - "Build cache of near-death threads so the values don't have to be recalculated on each request. - - Bugs: There is probably off-by-one somewhere in the calculation because thread at position 150 doesn't - have 100% chance of death which is weird, however, 99.333% is considered close enough for now" + "Build cache of near-death threads so the values don't have to be recalculated on each request." [pages-to-index pages-total threads-per-page threads-total] (vec (flatten (map (fn [single-page] ;; We have to (dec page-number) bcs otherwise we would get the total number of threads @@ -64,7 +61,7 @@ ;; universal calculation for total number of threads: ;; (pages-total-1) * threadsPerPage + threadsOnLastpage ;;accounts for boards which have stickied threads making them have 11pages threads-per-page (count (:threads (first catalog))) - threads-total (+ (* threads-per-page (dec pages-total) (count (last catalog)))) ;; Todo: Yeah, maybe this calculation could be refactored into let + 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))))