<commit_before>(ns user
  (:use plumbing.core)
  (:use criterium.core)
  (:require [clojure.core.reducers :as r]
            [clojure.pprint :refer [pprint pp]]
            [clojure.repl :refer :all]
            [clojure.tools.namespace.repl :refer [refresh]]
            [datomic.api :as d]
            [system]
            [lens.api :as api]
            [lens.schema :as schema]
            [lens.util :as util]))

(def system nil)

(defn init []
  (alter-var-root #'system (constantly (system/system (system/env)))))

(defn start []
  (alter-var-root #'system system/start))

(defn stop []
  (alter-var-root #'system system/stop))

(defn startup []
  (init)
  (start)
  (println "Server running at port" (:port system)))

(defn reset []
  (stop)
  (refresh :after 'user/startup))

;; Starting and Resetting the Server
(comment
  (startup)
  (reset))

(defn create-database []
  (d/create-database (:db-uri system)))

(defn connect []
  (d/connect (:db-uri system)))

(defn load-schema []
  (schema/load-schema (connect)))

(defn workbooks-by-user [db]
  (->> (api/all-users db)
       (r/map #(vector (:user/id %) (mapv :workbook/name (api/private-workbooks %))))
       (into [])))

(defn num-of-versions [db]
  (->> (api/all-versions db)
       (r/map (constantly 1))
       (reduce +)))

(defn num-of-queries [db]
  (->> (api/all-queries db)
       (r/map (constantly 1))
       (reduce +)))

(comment
  (create-database)
  (load-schema)
  (def conn (connect))
  (api/create-standard-workbook conn)
  (pst)
  (d/touch (first (api/queries (d/entity (d/db conn) 17592186045434))))

  (let [db (d/db conn)]
    (->> (d/q '[:find [?w ...] :where [?w :workbook/id]] db)
         (map #(d/entity db %))
         (map :workbook/id)))

  (api/workbook (d/db conn) "")

  @(d/transact conn [[:workbook.fn/create (d/tempid :db.part/user)]])

  )
<commit_msg>Cleanup Namespace User<commit_after>(ns user
  (:use plumbing.core)
  (:use criterium.core)
  (:require [clojure.pprint :refer [pprint pp]]
            [clojure.repl :refer :all]
            [clojure.tools.namespace.repl :refer [refresh]]
            [datomic.api :as d]
            [system]
            [lens.schema :as schema]))

(def system nil)

(defn init []
  (alter-var-root #'system (constantly (system/system (system/env)))))

(defn start []
  (alter-var-root #'system system/start))

(defn stop []
  (alter-var-root #'system system/stop))

(defn startup []
  (init)
  (start)
  (println "Server running at port" (:port system)))

(defn reset []
  (stop)
  (refresh :after 'user/startup))

(defn create-database []
  (d/create-database (:db-uri system)))

(defn connect []
  (d/connect (:db-uri system)))

(defn load-schema []
  (schema/load-schema (connect)))

;; Init Development
(comment
  (startup)
  (create-database)
  (load-schema)
  )

;; Reset after making changes
(comment
  (reset)
  )

;; Connection and Database in the REPL
(comment
  (def conn (connect))
  (def db (d/db conn))
  )

{'fraction_non_alphanumeric': 0.1801284217641095, 'fraction_numerical': 0.005407232173031429, 'mean_word_length': 2.849154746423927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2070839', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1100, 'n_words': 265}