          (boolean? count)
          (boolean? unseen)]}
   (let [order-fn (if (= order :desc) r/desc r/asc)
-        unseen-cap-sec (if (zero? config/unseen-cap-days)
-                         (* 60 60 24 365 50) ;; 50 years cap
-                         (* 60 60 24 config/unseen-cap-days))]
+        unseen-cap-ms (if (zero? config/unseen-cap-days)
+                        (* 60 60 24 365 50 1000) ;; 50 years cap
+                        (* 60 60 24 config/unseen-cap-days 1000))]
     (db-common/with-timeout db-common/default-timeout
       (as-> (r/table "entries") query
        (r/get-all query [[:published org-uuid]] {:index :status-org-uuid})

                    sort-value-base (-> sort-field
                                     (r/iso8601)
                                     (r/to-epoch-time)
                                     (r/round))
                    unseen-entry? (r/and (seq container-last-seen-at)
                                         (r/gt (r/get-field post-row :published-at) container-last-seen-at))
                    unseen-with-cap? (r/and unseen-entry?
                                            (r/gt sort-value-base
                                                  (-> (r/now) (r/to-epoch-time) (r/round) (r/sub unseen-cap-sec))))
                    sort-value (r/branch unseen-with-cap?
                                ;; If the item is unseen and was published (for recently posted) or bookmarked
                                ;; (for bookmarks) or last activity was (for recent activity) in the cap window
                                ;; let's add the cap window to the publish timestamp so it will sort before the seen ones
                                (r/add sort-value-base unseen-cap-sec)
                                ;; Or use the plain sort value in case it's seen or it's out of the cap window
                                sort-value-base)]
                {;; Date of the last added comment on this entry

        (boolean? unseen)]}
  (let [index-values (if (sequential? index-value) index-value [index-value])
        order-fn (if (= order :desc) r/desc r/asc)
        unseen-cap-ms (if (zero? config/unseen-cap-days)
                        (* 60 60 24 365 50 1000) ;; default is 50 years cap if no config is set
                        (* 60 60 24 config/unseen-cap-days 1000))]
    (db-common/with-timeout db-common/default-timeout
      (as-> (r/table table-name) query
            (r/get-all query index-values {:index index-name})
