Skip to content

Commit

Permalink
Fix parsing of ACeDB all classes identifier report.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Russell committed Jul 31, 2017
1 parent ff3ff50 commit 26122ec
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/pseudoace/qa.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
(def ^{:private true} report-headings
["ACeDB" "datomic" "Missing" "Added" "Identical"])

(defn- parse-csv-line [line-number line]
(try
(csv/parse-csv line)
(catch Exception e
(ex-info "Failed to parse CSV line"
{:line-number line-number
:line line}))))

(defn- write-append [writer record
& {:keys [verbose]
:or {verbose false}}]
Expand All @@ -36,9 +44,11 @@
Returns a mapping of className to set of identifiers per ACeDB class."
[acedb-report-path]
(with-open [rdr (io/reader acedb-report-path)]
(->> (csv/parse-csv rdr)
(->> (line-seq rdr)
(map-indexed parse-csv-line)
(map first)
(map merge-split-record)
(merge-pairs))))
(merge-pairs))))

(defrecord StatsReport [class-names entries])

Expand All @@ -56,14 +66,17 @@
(n-both [this]
(count (:both this))))

(defn db-data [db attr]
(->> (d/q '[:find [?v ...]
:in $ ?a
:where [_ ?a ?v]]
db attr)
(map pr-str)
set))

(defn- report-entry [db ref-data native->ref attr]
(let [class-name (native->ref attr)
db-values (->> (d/q '[:find [?v ...]
:in $ ?a
:where [_ ?a ?v]]
db attr)
(map pr-str)
set)
db-values (db-data db attr)
ref-values (set (ref-data class-name))
[ref-only db-only in-both] (diff ref-values db-values)]
(->StatsReportEntry class-name attr db-only ref-only in-both)))
Expand Down

0 comments on commit 26122ec

Please sign in to comment.