فهرست منبع

enhance: between support any :datetime property

Not just :block/created-at and :block/updated-at
Tienson Qin 9 ماه پیش
والد
کامیت
9af119ab29
2فایلهای تغییر یافته به همراه29 افزوده شده و 19 حذف شده
  1. 7 3
      src/main/frontend/components/query/builder.cljs
  2. 22 16
      src/main/frontend/db/query_dsl.cljs

+ 7 - 3
src/main/frontend/components/query/builder.cljs

@@ -13,10 +13,10 @@
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.query.builder :as query-builder]
             [frontend.mixins :as mixins]
-            [frontend.util.ref :as ref]
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.util :as util]
+            [frontend.util.ref :as ref]
             [logseq.common.util :as common-util]
             [logseq.common.util.page-ref :as page-ref]
             [logseq.db :as ldb]
@@ -506,9 +506,13 @@
                         (symbol? end))
                   (name end)
                   (second end))]
-        (str (if (= k :block/created-at)
+        (str (cond
+               (= k :block/created-at)
                "Created"
-               "Updated")
+               (= k :block/updated-at)
+               "Updated"
+               :else
+               (or (:block/title (db/entity k)) (name k)))
              " " start
              (when end
                (str " ~ " end))))

+ 22 - 16
src/main/frontend/db/query_dsl.cljs

@@ -19,6 +19,7 @@
             [logseq.common.util.date-time :as date-time-util]
             [logseq.common.util.page-ref :as page-ref]
             [logseq.db.file-based.rules :as file-rules]
+            [logseq.db.frontend.property :as db-property]
             [logseq.db.frontend.rules :as rules]
             [logseq.graph-parser.text :as text]))
 
@@ -208,25 +209,30 @@
 ;; ===============
 (defn- resolve-timestamp-property
   [e]
-  (let [k' (second e)]
-    (when (or (keyword? k') (symbol? k') (string? k'))
-      (let [k (-> k'
-                  (name)
-                  (string/lower-case)
-                  (string/replace "_" "-")
-                  keyword)]
-        (case k
-          :created-at
-          :block/created-at
-          :updated-at
-          :block/updated-at
-          k)))))
+  (let [k (second e)]
+    (when (or (keyword? k) (symbol? k) (string? k))
+      (let [k' (-> k
+                   (name)
+                   (string/lower-case)
+                   (string/replace "_" "-")
+                   keyword)]
+        (if (and (config/db-based-graph?) (db-property/property? k'))
+          k'
+          (case k'
+            :created-at
+            :block/created-at
+            :updated-at
+            :block/updated-at
+            nil))))))
 
 (defn get-timestamp-property
   [e]
-  (let [k (resolve-timestamp-property e)]
-    (when (contains? #{:block/created-at :block/updated-at} k)
-      k)))
+  (when-let [k (resolve-timestamp-property e)]
+    (if (config/db-based-graph?)
+      (when (keyword? k)
+        k)
+      (when (contains? #{:block/created-at :block/updated-at} k)
+        k))))
 
 (defn- build-journal-between-two-arg
   [e]