Skip to content

Commit

Permalink
fix: add new languages to language preferences with the value false
Browse files Browse the repository at this point in the history
  • Loading branch information
ozangulle committed Feb 7, 2025
1 parent a2ae03d commit 0373314
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/plauna/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
[plauna.analysis :as analysis]
[plauna.database :as db]
[plauna.messaging :as messaging]
[clojure.core.async :as async])
[clojure.core.async :as async]
[clojure.data :as cd])
(:import [java.net ServerSocket]
[org.eclipse.jetty.server Server]))

Expand Down Expand Up @@ -78,9 +79,12 @@
languages (filterv #(not (= "n/a" %)) (mapv :language (db/get-languages)))]
(if (empty? languages)
[]
(if (empty? preferences)
(do (db/add-language-preferences (map (comp #(conj % false) vector) languages))
(db/get-language-preferences))
(if (< (count preferences) (count languages))
(let [existing-languages-in-pref (mapv :language preferences)
diff (cd/diff (set existing-languages-in-pref) (set languages))]
(db/add-language-preferences
(mapv vector (second diff) (repeat (count (second diff)) false)))
(db/get-language-preferences))
preferences))))

(defn params->interval-request [params]
Expand Down

0 comments on commit 0373314

Please sign in to comment.