Use JSON isntead of EDN for history, 10x speedup.
This commit is contained in:
parent
7540a35af0
commit
4ee19d1a14
@ -6,7 +6,6 @@
|
||||
[cljs.reader :as reader]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[fipp.edn :as fippedn]
|
||||
[kitchen-async.promise :as p]
|
||||
[lemondronor.advisorycircular.adsbx :as adsbx]
|
||||
[lemondronor.advisorycircular.generation :as generation]
|
||||
@ -157,7 +156,7 @@
|
||||
|
||||
|
||||
(defn write-history-db [db path]
|
||||
(fs/writeFileSync path (with-out-str (fippedn/pprint db)))
|
||||
(fs/writeFileSync path (.stringify js/JSON (clj->js db) nil " "))
|
||||
db)
|
||||
|
||||
|
||||
@ -165,8 +164,8 @@
|
||||
;; resolves to the database value.
|
||||
|
||||
(defn read-history-db [path]
|
||||
(p/let [edn-str (util/read-file path {:encoding "utf-8"})
|
||||
db (reader/read-string edn-str)]
|
||||
(p/let [json-str (util/read-file path {:encoding "utf-8"})
|
||||
db (js->clj (.parse js/JSON json-str))]
|
||||
(log-verbose "Loaded %s aircraft from database %s" (count db) path)
|
||||
db))
|
||||
|
||||
@ -265,11 +264,6 @@
|
||||
v)))
|
||||
|
||||
|
||||
(defn debug-prn [x msg]
|
||||
(println msg (with-out-str (fippedn/pprint x)))
|
||||
x)
|
||||
|
||||
|
||||
(defn closest-airport [config lat lon]
|
||||
(p/let [results (pelias/nearby (:pelias config)
|
||||
lat lon
|
||||
@ -566,7 +560,7 @@
|
||||
;; close to an airport, then it's probably just doing flight
|
||||
;; training.
|
||||
:minimum-airport-distance-km 2.5
|
||||
:history-db-path "advisorycircular.edn"
|
||||
:history-db-path "advisorycircular.json"
|
||||
:basestation-sqb "basestation.sqb"
|
||||
:twitter {:enabled? true}})
|
||||
|
||||
@ -634,7 +628,7 @@
|
||||
(.option "--no-tweeting" "Do not tweet")
|
||||
(.option "--config <path>" "Path to the configuration yaml file")
|
||||
(.option "--secrets <path>" "Path to the secrets yaml file" "secrets.yaml")
|
||||
(.option "--history <path>" "Path to history/state file" "advisorycircular.edn")
|
||||
(.option "--history <path>" "Path to history/state file" "advisorycircular.json")
|
||||
(.option "--log-prefix <prefix>" "Log prefix to use")
|
||||
(.parse (.-argv js/process)))
|
||||
(logging/set-log-prefix! (or (.-logPrefix commander) ""))
|
||||
|
Loading…
Reference in New Issue
Block a user