Skip to content

Commit 7bb8655

Browse files
chore: remove unused errors-by-type
1 parent 79e7506 commit 7bb8655

File tree

3 files changed

+13
-30
lines changed

3 files changed

+13
-30
lines changed

deps/cli/src/logseq/cli/commands/validate.cljs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
(->> (map (fn [e] (dissoc e :db/id)) ent-maps) explainer not-empty))]
2020
(let [ent-errors
2121
(->> (db-validate/group-errors-by-entity db ent-maps (:errors explanation))
22-
(map #(-> (dissoc % :errors-by-type)
23-
(update :errors (fn [errs]
24-
;; errs looks like: {178 {:logseq.property/hide? ["disallowed key"]}}
25-
;; map is indexed by :in which is unused since all errors are for the same map
26-
(->> (me/humanize {:errors errs})
27-
vals
28-
(apply merge-with into)))))))]
22+
(map #(update % :errors
23+
(fn [errs]
24+
;; errs looks like: {178 {:logseq.property/hide? ["disallowed key"]}}
25+
;; map is indexed by :in which is unused since all errors are for the same map
26+
(->> (me/humanize {:errors errs})
27+
vals
28+
(apply merge-with into))))))]
2929
(println "Found" (count ent-errors)
3030
(if (= 1 (count ent-errors)) "entity" "entities")
3131
"with errors:")

deps/db/script/validate_db.cljs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
verbose
2727
(pprint/pprint ent-errors)
2828
humanize
29-
(pprint/pprint (map #(-> (dissoc % :errors-by-type)
30-
(update :errors (fn [errs]
31-
(->> (me/humanize {:errors errs})
32-
vals
33-
(apply merge-with into)))))
29+
(pprint/pprint (map #(update % :errors (fn [errs]
30+
(->> (me/humanize {:errors errs})
31+
vals
32+
(apply merge-with into))))
3433
ent-errors))
3534
:else
3635
(pprint/pprint (map :entity ent-errors))))

deps/db/src/logseq/db/frontend/validate.cljs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,7 @@
7777
(fn [id] (select-keys (d/entity db id)
7878
[:block/name :block/tags :db/id :block/created-at]))))
7979
:dispatch-key (->> (dissoc ent :db/id) (db-malli-schema/entity-dispatch-key db))
80-
:errors errors'
81-
;; Group by type to reduce verbosity
82-
;; TODO: Move/remove this to another fn if unused
83-
:errors-by-type
84-
(->> (group-by :type errors')
85-
(map (fn [[type' type-errors]]
86-
[type'
87-
{:in-value-distinct (->> type-errors
88-
(map #(select-keys % [:in :value]))
89-
distinct
90-
vec)
91-
:schema-distinct (->> (map :schema type-errors)
92-
(map m/form)
93-
distinct
94-
vec)}]))
95-
(into {}))})))))
80+
:errors errors'})))))
9681

9782
(defn validate-db!
9883
"Validates all the entities of the given db using :eavt datoms. Returns a map
@@ -112,8 +97,7 @@
11297
(cond-> {:datom-count (count datoms)
11398
:entities ent-maps*}
11499
(some? errors)
115-
(assoc :errors (map #(-> (dissoc % :errors-by-type)
116-
(update :errors (fn [errs] (me/humanize {:errors errs}))))
100+
(assoc :errors (map #(update % :errors (fn [errs] (me/humanize {:errors errs})))
117101
(group-errors-by-entity db ent-maps errors))))))
118102

119103
(defn graph-counts

0 commit comments

Comments
 (0)