Browse Source

fix: 2 async queries that are not transacting in client

Fixed these queries by converting them to return maps
which <q expects. Fixes LOG-3059
Gabriel Horner 2 years ago
parent
commit
de9397e00f
2 changed files with 14 additions and 13 deletions
  1. 11 11
      src/main/frontend/db/async.cljs
  2. 3 2
      src/main/frontend/db/async/util.cljs

+ 11 - 11
src/main/frontend/db/async.cljs

@@ -29,11 +29,10 @@
   [graph]
   (p/let [result (<q
                   graph
-                  '[:find ?path ?modified-at
+                  '[:find [(pull ?file [:file/path :file/last-modified-at]) ...]
                     :where
-                    [?file :file/path ?path]
-                    [(get-else $ ?file :file/last-modified-at 0) ?modified-at]])]
-    (->> result seq reverse)))
+                    [?file :file/path ?path]])]
+    (->> result seq reverse (map #(vector (:file/path %) (or (:file/last-modified-at %) 0))))))
 
 (defn <get-all-templates
   [graph]
@@ -50,14 +49,15 @@
     (p/let [templates (<get-all-templates repo)]
       (get templates name))))
 
-(defn <db-based-get-all-properties
-  ":block/type could be one of [property, class]."
+(defn- <db-based-get-all-properties
+  "Return seq of property names. :block/type could be one of [property, class]."
   [graph]
-  (<q graph
-      '[:find [?n ...]
-        :where
-        [?e :block/type "property"]
-        [?e :block/original-name ?n]]))
+  (p/let [result (<q graph
+                     '[:find [(pull ?e [:block/original-name]) ...]
+                       :where
+                       [?e :block/type "property"]
+                       [?e :block/original-name]])]
+    (map :block/original-name result)))
 
 (defn <get-all-properties
   "Returns a seq of property name strings"

+ 3 - 2
src/main/frontend/db/async/util.cljs

@@ -21,12 +21,13 @@
                                (apply concat result')
                                result')
                              (remove nil?))]
-                (when (every? map? tx-data)
+                (if (every? map? tx-data)
                   (try
                     (d/transact! conn tx-data)
                     (catch :default e
                       (js/console.error "<q failed with:" e)
-                      nil))))))
+                      nil))
+                  (js/console.log "<q skipped tx for inputs:" inputs)))))
           result')))))
 
 (defn <pull