                     sort-value-base (-> sort-field
                                      (r/iso8601)
                                      (r/to-epoch-time)
+                                     (r/mul 1000)
                                      (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))))
+                                                  (-> (r/now) (r/to-epoch-time) (r/mul 1000) (r/round) (r/sub unseen-cap-ms))))
                     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)
+                                (r/add sort-value-base unseen-cap-ms)
                                 ;; 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-sec (if (zero? config/unseen-cap-days)
                        (* 60 60 24 365 50) ;; default is 50 years cap if no config is set
                        (* 60 60 24 config/unseen-cap-days))]
    (db-common/with-timeout db-common/default-timeout
      (as-> (r/table table-name) query
            (r/get-all query index-values {:index index-name})

                    sort-value (-> last-activity-at
                                (r/iso8601)
                                (r/to-epoch-time)
                                (r/mul 1000)
                                (r/round))]
                {:last-activity-at last-activity-at
                 :sort-value sort-value})))
