<commit_before>(ns web.reconciler
  (:import [goog.net XhrIo])
  (:require [cljs.core.async :refer [<! timeout]]
            [clojure.string :as str]
            [cognitect.transit :as transit]
            [om.next :as om]
            [om.next.protocols :as om-protocols]
            [web.env :as env])
  (:require-macros [cljs.core.async.macros :refer [go]]))

;;;; Initial state

(def initial-state {})

;;;; Parser

(defmulti read om/dispatch)

(defmulti mutate om/dispatch)

(def parser
  (om/parser {:read read :mutate mutate}))

;;;; CUSTARD data

(defmethod read :states
  [{:keys [state query]} key _]
  (let [st @state]
    {:value (om/db->tree query (get st key) st)
     :remote true}))

(defmethod read :state
  [{:keys [state query]} key params]
  {:value (get-in @state (:state params))
   :remote true})

(defmethod read :project
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (om/db->tree query (get st key) st)
     :remote true}))

(defmethod read :requirements
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (om/db->tree query (get st key) st)
     :remote true}))

(defmethod read :components
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (om/db->tree query (get st key) st)
     :remote true}))

(defmethod read :tags
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (om/db->tree query (get st key) st)
     :remote true}))

(defmethod read :work-items
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (om/db->tree query (get st key) st)
     :remote true}))

;;;; UI state<commit_msg>Speed query times up by 50% using a memoized db->tree<commit_after>(ns web.reconciler
  (:import [goog.net XhrIo])
  (:require [cljs.core.async :refer [<! timeout]]
            [clojure.string :as str]
            [cognitect.transit :as transit]
            [om.next :as om]
            [om.next.protocols :as om-protocols]
            [web.env :as env])
  (:require-macros [cljs.core.async.macros :refer [go]]))

;;;; Initial state

(def initial-state {})

;;;; Parser

(defmulti read om/dispatch)

(defmulti mutate om/dispatch)

(def parser
  (om/parser {:read read :mutate mutate}))

;;;; CUSTARD data

(def db->tree-cached (memoize om/db->tree))

(defmethod read :states
  [{:keys [state query]} key _]
  (let [st @state]
    {:value (db->tree-cached query (get st key) st)
     :remote true}))

(defmethod read :state
  [{:keys [state query]} key params]
  {:value (get-in @state (:state params))
   :remote true})

(defmethod read :project
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (db->tree-cached query (get st key) st)
     :remote true}))

(defmethod read :requirements
  [{:keys [state query]} key params]
  (println "read :requirements")
  (let [st @state]
    {:value (db->tree-cached query (get st key) st)
     :remote true}))

(defmethod read :components
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (db->tree-cached query (get st key) st)
     :remote true}))

(defmethod read :tags
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (db->tree-cached query (get st key) st)
     :remote true}))

(defmethod read :work-items
  [{:keys [state query]} key params]
  (let [st @state]
    {:value (db->tree-cached query (get st key) st)
     :remote true}))

;;;; UI state
{'fraction_non_alphanumeric': 0.1673615247170935, 'fraction_numerical': 0.0005955926146515784, 'mean_word_length': 3.162329615861214, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1968331', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1182, 'n_words': 383}