Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defn- log-insertion-counts
([] (rf))
([session] (rf session))
([session batch]
(let [before-session session
after-session (rf session batch)]
(send-off logging-agent
(fn [_]
(let [before (into {} (map (fn [[k v]] [(:name k) (count v)])) (:insertions (inspect before-session)))
after (into {} (map (fn [[k v]] [(:name k) (count v)])) (:insertions (inspect after-session)))
delta (reduce-kv (fn [m k v]
(assoc m k (- (get after k 0) (get before k 0))))
(log/info "session-from-db: insertion counts:"
(->> delta
(map (fn [[k v]]
(let [k (-> k str read-string name)]
{:rule k, :count v})))
(remove (comp zero? :count))
(sort-by (juxt :count :rule))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.