Fixed issue where callsign was redundantly tweeted.

This commit is contained in:
John Wiseman 2020-09-26 22:09:56 -07:00
parent 05b96b612b
commit 0f07b705c1
1 changed files with 18 additions and 17 deletions

View File

@ -110,14 +110,14 @@
(defn get-adsbexchange-live-data [{:keys [url lat lon radius-nm api-key api-whitelist rapid-api?]}]
(let [url (str
(->> [url
"lat" lat
"lon" lon
"dist" (.toFixed radius-nm (if rapid-api? 0 1))]
(map str)
(string/join "/"))
;; RapidAPI expects a trailing slash.
(if rapid-api? "/" ""))
(->> [url
"lat" lat
"lon" lon
"dist" (.toFixed radius-nm (if rapid-api? 0 1))]
(map str)
(string/join "/"))
;; RapidAPI expects a trailing slash.
(if rapid-api? "/" ""))
headers (cond-> (if rapid-api?
{:x-rapidapi-key api-key :x-rapidapi-host (:host (c-url/url url)) :useQueryString true}
{:auth-key api-key})
@ -523,19 +523,20 @@
(defn template-data [ac ac-db-rec reverse nearby]
(let [rev-props (:properties reverse)
nearby (:properties nearby)
info (cond-> (-> ac
(dissoc :history :type)
(merge rev-props)
(merge-adsbx-aircraft-db-rec ac-db-rec))
info (-> ac
(dissoc :history :type)
(merge rev-props)
(merge-adsbx-aircraft-db-rec ac-db-rec))
info (cond-> info
(:military? ac)
(-> (assoc :militaryregistration (:registration ac)
:militaryicao (:icao ac)))
(-> (assoc :militaryregistration (:registration info)
:militaryicao (:icao info)))
nearby
(assoc :nearbylandmark (:name nearby)
:nearbydistance (-> nearby :distance km->miles (to-fixed 2)))
(:speed ac)
(assoc :speed (.toFixed (* (:speed ac) 1.15078) 0))
(= (:registration ac) (:callsign ac))
(:speed info)
(assoc :speed (.toFixed (* (:speed info) 1.15078) 0))
(= (:registration info) (:callsign info))
(dissoc :callsign)
;; TODO: If layer is "county", find the nearest city.
)]