Просмотр исходного кода

fix: task sort by scheduled field make empty rows disappeared

fixes https://github.com/logseq/db-test/issues/315
Tienson Qin 8 месяцев назад
Родитель
Сommit
1cac99d0c0
1 измененных файлов с 24 добавлено и 21 удалено
  1. 24 21
      deps/db/src/logseq/db/common/view.cljs

+ 24 - 21
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)))