From 4ee19d1a1426502b6b66072ab278f542231162a5 Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Mon, 25 May 2020 15:39:07 -0700 Subject: [PATCH] Use JSON isntead of EDN for history, 10x speedup. --- src/main/lemondronor/advisorycircular.cljs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/lemondronor/advisorycircular.cljs b/src/main/lemondronor/advisorycircular.cljs index 794471f..16b302e 100644 --- a/src/main/lemondronor/advisorycircular.cljs +++ b/src/main/lemondronor/advisorycircular.cljs @@ -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 to the configuration yaml file") (.option "--secrets " "Path to the secrets yaml file" "secrets.yaml") - (.option "--history " "Path to history/state file" "advisorycircular.edn") + (.option "--history " "Path to history/state file" "advisorycircular.json") (.option "--log-prefix " "Log prefix to use") (.parse (.-argv js/process))) (logging/set-log-prefix! (or (.-logPrefix commander) ""))