From 1cac99d0c09daaeaeaec41f3cd250587c4259815 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Thu, 12 Jun 2025 19:26:42 +0800 Subject: [PATCH] fix: task sort by scheduled field make empty rows disappeared fixes https://github.com/logseq/db-test/issues/315 --- deps/db/src/logseq/db/common/view.cljs | 45 ++++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/deps/db/src/logseq/db/common/view.cljs b/deps/db/src/logseq/db/common/view.cljs index f767e88b29..d9c146cec6 100644 --- a/deps/db/src/logseq/db/common/view.cljs +++ b/deps/db/src/logseq/db/common/view.cljs @@ -86,28 +86,29 @@ (not asc?) reverse) - (not (ldb/db-based-graph? db)) ; file graph properties don't support index - (sort (common-util/by-sorting - [{:get-value get-value-fn - :asc? asc?}]) entities) - :else - (let [ref-type? (= :db.type/ref (:db/valueType property))] - (if ref-type? - (sort-ref-entities-by-single-property entities sorting get-value-fn) - (let [datoms (cond-> - (->> (d/datoms db :avet id) - (common-util/distinct-by :e) - vec) - (not asc?) - rseq) - row-ids (set (map :db/id entities)) - id->row (zipmap (map :db/id entities) entities)] - (keep - (fn [d] - (when (row-ids (:e d)) - (id->row (:e d)))) - datoms))))) + (sort-ref-entities-by-single-property entities sorting get-value-fn) + + ;; (let [ref-type? (= :db.type/ref (:db/valueType property))] + ;; (if ref-type? + ;; (sort-ref-entities-by-single-property entities sorting get-value-fn) + + ;; ;; FIXME: entity may not have the value + ;; ;; (let [datoms (cond-> + ;; ;; (->> (d/datoms db :avet id) + ;; ;; (common-util/distinct-by :e) + ;; ;; vec) + ;; ;; (not asc?) + ;; ;; rseq) + ;; ;; row-ids (set (map :db/id entities)) + ;; ;; id->row (zipmap (map :db/id entities) entities)] + ;; ;; (keep + ;; ;; (fn [d] + ;; ;; (when (row-ids (:e d)) + ;; ;; (id->row (:e d)))) + ;; ;; datoms)) + ;; )) + ) distinct)] (if partition? (partition-by get-value-fn sorted-entities) @@ -132,6 +133,8 @@ minor-sorting (seq (rest sorting)) major-sorted-entities (sort-by-single-property db major-sorting entities (not-empty minor-sorting))] + (prn :debug :count (count entities) + :sorted (count major-sorted-entities)) (if minor-sorting (sort-entities-by-minor-sorting db major-sorted-entities minor-sorting) major-sorted-entities)))