<commit_before>(ns ^:figwheel-always potoo.core
  (:require [reagent.core :as r]
            [ajax.core :refer [GET POST]]))

(defonce app-state
  (r/atom {:potoos []}))

(defn potoo [p]
  (let [{:keys [text name date]} p]
    [:li
     [:span (str text ", " name ", " date)]]))

(defn potoo-list []
  (fn []
    (GET "/api/potoos" {:keywords? true
                        :response-format :json
                        :handler #(swap! app-state assoc :potoos %)})
    [:div
     [:h1 "Potooooooos!"]
     [:ul
      (for [p (:potoos @app-state)]
        ^{:key p} [potoo p])]]))

(defn ^:export run []
  (r/render
    [potoo-list]
    (js/document.getElementById "app")))

(run)

;; demo

(comment
  (defn cp [text]
    (let [name "Mr. Meeseeks"
          date (str (js/Date.))
          potoo {:key "zxc" :text text :name name :date date}]
      (swap! app-state update-in [:potoos] conj potoo))))
<commit_msg>Use react's get-initial-state for potoo list<commit_after>(ns ^:figwheel-always potoo.core
  (:require [reagent.core :as r]
            [ajax.core :refer [GET POST]]))

(defonce app-state
  (r/atom {:potoos []}))

(defn potoo [p]
  (let [{:keys [text name date]} p]
    [:li
     [:span (str text ", " name ", " date)]]))

(defn potoo-list []
  [:div
   [:h1 "Potooooooos!"]
   [:ul
    (for [p (:potoos @app-state)]
      ^{:key p} [potoo p])]])

(def potoo-list-initial
  (with-meta potoo-list
    {:get-initial-state
     (fn [_]
       (GET "/api/potoos" {:keywords? true
                           :response-format :json
                           :handler #(swap! app-state assoc :potoos %)}))}))

(defn ^:export run []
  (r/render
    [potoo-list-initial]
    (js/document.getElementById "app")))

(run)

;; demo

(comment
  (defn cp [text]
    (let [name "Mr. Meeseeks"
          date (str (js/Date.))
          potoo {:key "zxc" :text text :name name :date date}]
      (swap! app-state update-in [:potoos] conj potoo))))

{'fraction_non_alphanumeric': 0.18775720164609053, 'fraction_numerical': 0.00102880658436214, 'mean_word_length': 2.302207130730051, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '1274924', 'n_tokens_mistral': 758, 'n_tokens_neox': 727, 'n_words': 192}