<commit_before>(ns gtfve.controllers.api
  (:require-macros [cljs.core.async.macros :refer [go go-loop]]
                   [gtfve.macros :refer [<?]])
  (:require [om.core :as om]
            [cljs.core.async :as async :refer [put! <! close!]]))

(defmulti api-event
  (fn [event status args state cursors] [event status]))

(defmethod api-event :default
  [event status args state cursors]
  (.apply (.-error js/console) js/console (clj->js [event status args])))

(defmethod api-event [:stops-search :success] [event status [result query] state cursors]
  (let [data (:data cursors)
        stops-panel (:stops-panel cursors)
        results (:response result)]
    (om/update! (stops-panel) :last-query query)
    (om/update! (stops-panel) :loading? false)
    (om/update! (data) :stops-search-results results)))

(defmethod api-event [:stops-view :success] [event status [result] state cursors]
  (let [data (:data cursors)
        stops-panel (:stops-panel cursors)
        results (:response result)
        key-val-xf (map (fn [stop] [(:db/id stop) stop]))
        results-map (transduce key-val-xf conj {} results)]
    (om/update! (data) :stops results-map)))<commit_msg>Stops-view transacts to entities map<commit_after>(ns gtfve.controllers.api
  (:require-macros [cljs.core.async.macros :refer [go go-loop]]
                   [gtfve.macros :refer [<?]])
  (:require [om.core :as om]
            [cljs.core.async :as async :refer [put! <! close!]]
            [gtfve.utils :as utils]))

(defmulti api-event
  (fn [event status args state cursors] [event status]))

(defmethod api-event :default
  [event status args state cursors]
  (.apply (.-error js/console) js/console (clj->js [event status args])))

(defmethod api-event [:stops-search :success] [event status [result query] state cursors]
  (let [data (:data cursors)
        stops-panel (:stops-panel cursors)
        results (:response result)]
    (om/update! (stops-panel) :last-query query)
    (om/update! (stops-panel) :loading? false)
    (om/update! (data) :stops-search-results results)))

(defmethod api-event [:stops-view :success] [event status [result] state cursors]
  (let [data (:data cursors)
        stops-panel (:stops-panel cursors)
        results (:response result)
        key-val-xf (map (fn [stop] [(:db/id stop) stop]))
        results-map (transduce key-val-xf conj {} results)]
    (om/transact! (data) :entities #(utils/deep-merge % results-map))
    (om/update! (data) :stops (keys results-map))))
{'fraction_non_alphanumeric': 0.15812650120096078, 'fraction_numerical': 0.0, 'mean_word_length': 3.3310225303292893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '7132059', 'n_tokens_mistral': 865, 'n_tokens_neox': 840, 'n_words': 236}