           (r/filter query (r/fn [row]
             ;; All records after/before the start
             (dir-filter row)))
-          query)
-        (if-not count?
-          (r/order-by query (order-fn :sort-value))
           query)
            ;; Apply count if needed
         (if count? (r/count query) query)

         (#{:after :before} direction)
         (integer? limit)
         (boolean? count?)]}
  (let [order-fn (if (= order :desc) r/desc r/asc)]
    (db-common/with-timeout db-common/default-timeout
      (as-> (r/table table-name) query
        (r/get-all query index-value {:index index-name})
        ;; Filter out:
        (if-not (string/blank? start)
          (r/filter query (r/fn [row]
            (direction-filter direction start (r/get-field row :published-at))))
          query)
        (if-not count?
          (r/order-by query (order-fn :published-at))

         (boolean? count?)
         (boolean? unseen)]}
  (let [order-fn (if (= order :desc) r/desc r/asc)
        dir-filter (when-not (string/empty-or-nil? start)
                     #(direction-filter direction start (r/get-field % [:reduction :created-at])))
        uns-filter (when (and unseen container-last-seen-at)
                      #(unseen-filter container-last-seen-at (r/get-field % [:reduction :created-at])))
