<commit_before>(ns com.lemondronor.orbital-detector.createdb
  ""
  (:require [clojure.java.jdbc :as jdbc]
            [com.lemondronor.orbital-detector.planeplotter :as orbdet]))

(set! *warn-on-reflection* true)


(def db-spec
  {:classname   "org.sqlite.JDBC"
   :subprotocol "sqlite"
   :subname     "orbital.db"
   })


(defn create-tables [db]
  (jdbc/db-do-commands
   db
   "CREATE TABLE IF NOT EXISTS reports (timestamp integer, icao text, registration text, altitude integer, lat real, lon real, speed real, heading real)"))

   ;; (println (jdbc/create-table-ddl
   ;;  :reports
   ;;  [:timestamp :integer]
   ;;  [:icao :text]
   ;;  [:registration :text]
   ;;  [:altitude :integer]
   ;;  [:lat :real]
   ;;  [:lon :real]
   ;;  [:speed :real]
   ;;  [:heading :real]))))


(defn add-records [log]
  (jdbc/with-db-transaction [t-con db-spec]
    (doseq [r log]
      (jdbc/insert!
       t-con
       :reports
       {:timestamp (long (/ (:timestamp r) 1000))
        :icao (:icao r)
        :registration (:registration r)
        :altitude (:altitude r)
        :lat (:lat (:position r))
        :lon (:lon (:position r))
        :speed (:speed r)
        :heading (:heading r)}))))


<commit_msg>Added type column. Keep timestamp as datetime object.<commit_after>(ns com.lemondronor.orbital-detector.createdb
  ""
  (:require [clj-time.coerce :as timecoerce]
            [clojure.java.jdbc :as jdbc]
            [com.lemondronor.orbital-detector.planeplotter :as orbdet]))

(set! *warn-on-reflection* true)


(def db-spec
  {:classname   "org.sqlite.JDBC"
   :subprotocol "sqlite"
   :subname     "orbital.db"
   })


(defn create-tables [db]
  (jdbc/db-do-commands
   db
   "CREATE TABLE IF NOT EXISTS reports (timestamp integer, icao text, registration text, type text, altitude integer, lat real, lon real, speed real, heading real)"))

   ;; (println (jdbc/create-table-ddl
   ;;  :reports
   ;;  [:timestamp :integer]
   ;;  [:icao :text]
   ;;  [:registration :text]
   ;;  [:altitude :integer]
   ;;  [:lat :real]
   ;;  [:lon :real]
   ;;  [:speed :real]
   ;;  [:heading :real]))))


(defn add-records [log]
  (jdbc/with-db-transaction [t-con db-spec]
    (doseq [r log]
      (jdbc/insert!
       t-con
       :reports
       {:timestamp (long (/ (timecoerce/to-long (:timestamp r)) 1000))
        :icao (:icao r)
        :registration (:registration r)
        :altitude (:altitude r)
        :lat (:lat (:position r))
        :lon (:lon (:position r))
        :speed (:speed r)
        :heading (:heading r)}))))



{'fraction_non_alphanumeric': 0.16345776031434184, 'fraction_numerical': 0.003143418467583497, 'mean_word_length': 2.679190751445087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5038121', 'n_tokens_mistral': 989, 'n_tokens_neox': 878, 'n_words': 225}