<commit_before>(ns movement.util
  (:import goog.History)
  (:require
    [goog.events :as events]
    [goog.dom :as gdom]
    [goog.crypt.base64 :as b64]
    [goog.history.EventType :as EventType]
    [reagent.session :as session]
    [secretary.core :as secretary
     :include-macros true :refer [dispatch!]]
    [dommy.core :as dommy :refer-macros [sel1]]
    [ajax.core :as cljs-ajax :refer [to-interceptor]]
    [ajax.edn :refer [edn-request-format edn-response-format]]))

(def csrf-token
  (dommy/attr (sel1 :#anti-forgery-token) "value"))

(defn GET [url & [opts]]
  (let [base-opts {:format          (edn-request-format)
                   :response-format (edn-response-format)
                   :with-credentials true
                   :interceptors    [(to-interceptor {:name    "Token Interceptor"
                                                      :request #(assoc-in % [:headers "authorization"]
                                                                          (str "Token " (session/get :token)))})]}]
    (cljs-ajax/GET url (merge base-opts opts))))

(defn POST [url & [opts]]
  (let [base-opts {:format          (edn-request-format)
                   :response-format (edn-response-format)
                   :with-credentials true
                   :interceptors    [(to-interceptor {:name    "Token Interceptor"
                                                      :request #(assoc-in % [:headers "authorization"]
                                                                          (str "Token " (session/get :token)))})]
                   :headers {:x-csrf-token csrf-token}}]
    (cljs-ajax/POST url (merge base-opts opts))))

(defn get-templates []
  (if-let [user (session/get :user)]
    (GET "templates" {:params        {:user user}
                      :handler       #(session/put! :templates %)
                      :error-handler #(print (str "error retrieving templates: " %))})
    (print "no user in session.")))

(defn get-equipment []
  (if-let [user (session/get :user)]
    (GET "equipment" {:params        {:user user}<commit_msg>Remove with credentials, do str concat before setting header.<commit_after>(ns movement.util
  (:import goog.History)
  (:require
    [goog.events :as events]
    [goog.dom :as gdom]
    [goog.crypt.base64 :as b64]
    [goog.history.EventType :as EventType]
    [reagent.session :as session]
    [secretary.core :as secretary
     :include-macros true :refer [dispatch!]]
    [dommy.core :as dommy :refer-macros [sel1]]
    [ajax.core :as cljs-ajax :refer [to-interceptor]]
    [ajax.edn :refer [edn-request-format edn-response-format]]))

(def csrf-token
  (dommy/attr (sel1 :#anti-forgery-token) "value"))

(defn GET [url & [opts]]
  (let [token (str "Token " (session/get :token))
        base-opts {:format          (edn-request-format)
                   :response-format (edn-response-format)
                   :interceptors    [(to-interceptor {:name    "Token Interceptor"
                                                      :request #(assoc-in % [:headers "authorization"]
                                                                          token)})]}]
    (cljs-ajax/GET url (merge base-opts opts))))

(defn POST [url & [opts]]
  (let [token (str "Token " (session/get :token))
        base-opts {:format          (edn-request-format)
                   :response-format (edn-response-format)
                   :interceptors    [(to-interceptor {:name    "Token Interceptor"
                                                      :request #(assoc-in % [:headers "authorization"] token)})]
                   :headers {:x-csrf-token csrf-token}}]
    (cljs-ajax/POST url (merge base-opts opts))))

(defn get-templates []
  (if-let [user (session/get :user)]
    (GET "templates" {:params        {:user user}
                      :handler       #(session/put! :templates %)
                      :error-handler #(print (str "error retrieving templates: " %))})
    (print "no user in session.")))

(defn get-equipment []
  (if-let [user (session/get :user)]
    (GET "equipment" {:params        {:user user}
{'fraction_non_alphanumeric': 0.13980582524271845, 'fraction_numerical': 0.002912621359223301, 'mean_word_length': 1.7920054200542006, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3715743', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1186, 'n_words': 299}