<commit_before>(ns conference-rating.backend
  (:require [ajax.core :as ajax]
            [conference-rating.history :as history]
            [conference-rating.util :as util]))

(defn- unsanitise-location [conference-data]
  (if (not (nil? (:location conference-data)))
    (assoc-in conference-data [:location :name] (util/unescape (:name (:location conference-data))))
    conference-data))

(defn- unsanitize [conference-data]
  (let [location-escaped-data (unsanitise-location conference-data)]
    (assoc location-escaped-data :name (util/unescape (:name location-escaped-data))
                         :series (util/unescape (:series location-escaped-data))
                         :description (util/unescape (:description location-escaped-data)))))

(defn ajaxless-load-conference [id success-handler ajax-fn]
  (ajax-fn (str "/api/conferences/" id) {:handler (fn [conference] (success-handler (unsanitize conference)))
                                          :error-handler #(js/alert "Conference not found.")<commit_msg>Clean up sanitising code to make it easier to read<commit_after>(ns conference-rating.backend
  (:require [ajax.core :as ajax]
            [conference-rating.history :as history]
            [conference-rating.util :as util]))

(defn- unsanitise-location [location]
  (if (not (nil? location))
    (update location :name util/unescape)))

(defn- unsanitize [conference-data]
  (let [location-escaped-data (unsanitise-location conference-data)]
    (-> location-escaped-data
        (update :name util/unescape)
        (update :series util/unescape)
        (update :description util/unescape)
        (update :location unsanitise-location))))

(defn ajaxless-load-conference [id success-handler ajax-fn]
  (ajax-fn (str "/api/conferences/" id) {:handler (fn [conference] (success-handler (unsanitize conference)))
                                          :error-handler #(js/alert "Conference not found.")
{'fraction_non_alphanumeric': 0.1333676622039135, 'fraction_numerical': 0.0, 'mean_word_length': 3.064853556485356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '809224', 'n_tokens_mistral': 583, 'n_tokens_neox': 569, 'n_words': 141}