Browse Source

chore: remove unused errors-by-type

Gabriel Horner 2 weeks ago
parent
commit
7bb8655d71

+ 7 - 7
deps/cli/src/logseq/cli/commands/validate.cljs

@@ -19,13 +19,13 @@
                            (->> (map (fn [e] (dissoc e :db/id)) ent-maps) explainer not-empty))]
       (let [ent-errors
             (->> (db-validate/group-errors-by-entity db ent-maps (:errors explanation))
-                 (map #(-> (dissoc % :errors-by-type)
-                           (update :errors (fn [errs]
-                                             ;; errs looks like: {178 {:logseq.property/hide? ["disallowed key"]}}
-                                             ;; map is indexed by :in which is unused since all errors are for the same map
-                                             (->> (me/humanize {:errors errs})
-                                                  vals
-                                                  (apply merge-with into)))))))]
+                 (map #(update % :errors
+                               (fn [errs]
+                                 ;; errs looks like: {178 {:logseq.property/hide? ["disallowed key"]}}
+                                 ;; map is indexed by :in which is unused since all errors are for the same map
+                                 (->> (me/humanize {:errors errs})
+                                      vals
+                                      (apply merge-with into))))))]
         (println "Found" (count ent-errors)
                  (if (= 1 (count ent-errors)) "entity" "entities")
                  "with errors:")

+ 4 - 5
deps/db/script/validate_db.cljs

@@ -26,11 +26,10 @@
               verbose
               (pprint/pprint ent-errors)
               humanize
-              (pprint/pprint (map #(-> (dissoc % :errors-by-type)
-                                       (update :errors (fn [errs]
-                                                         (->> (me/humanize {:errors errs})
-                                                              vals
-                                                              (apply merge-with into)))))
+              (pprint/pprint (map #(update % :errors (fn [errs]
+                                                       (->> (me/humanize {:errors errs})
+                                                            vals
+                                                            (apply merge-with into))))
                                   ent-errors))
               :else
               (pprint/pprint (map :entity ent-errors))))

+ 2 - 18
deps/db/src/logseq/db/frontend/validate.cljs

@@ -77,22 +77,7 @@
                                    (fn [id] (select-keys (d/entity db id)
                                                          [:block/name :block/tags :db/id :block/created-at]))))
                  :dispatch-key (->> (dissoc ent :db/id) (db-malli-schema/entity-dispatch-key db))
-                 :errors errors'
-               ;; Group by type to reduce verbosity
-               ;; TODO: Move/remove this to another fn if unused
-                 :errors-by-type
-                 (->> (group-by :type errors')
-                      (map (fn [[type' type-errors]]
-                             [type'
-                              {:in-value-distinct (->> type-errors
-                                                       (map #(select-keys % [:in :value]))
-                                                       distinct
-                                                       vec)
-                               :schema-distinct (->> (map :schema type-errors)
-                                                     (map m/form)
-                                                     distinct
-                                                     vec)}]))
-                      (into {}))})))))
+                 :errors errors'})))))
 
 (defn validate-db!
   "Validates all the entities of the given db using :eavt datoms. Returns a map
@@ -112,8 +97,7 @@
     (cond-> {:datom-count (count datoms)
              :entities ent-maps*}
       (some? errors)
-      (assoc :errors (map #(-> (dissoc % :errors-by-type)
-                               (update :errors (fn [errs] (me/humanize {:errors errs}))))
+      (assoc :errors (map #(update % :errors (fn [errs] (me/humanize {:errors errs})))
                           (group-errors-by-entity db ent-maps errors))))))
 
 (defn graph-counts