<commit_before>
(ns notv.core
  (:gen-class)
  (:require [notv.render :as render]
            [notv.xml :as xml]
            [clojure.java.io :as io]
            [compojure.core :refer :all]
            [compojure.route :as route]
            [org.httpkit.server :refer [run-server]]))

;; tää kuuluis varmaan coreen
(defn get-tvdata-file-location []
  (let [env-path (System/getenv "TVDATA_FILE")]
    (if (empty? env-path)
      (io/file (io/resource "example-tvdata.xml"))
      env-path)))

(defn get-tvdata
  []
  (slurp (get-tvdata-file-location)))

(defn get-revision
  []
  (if-let [file (io/file (io/resource "gitrevision.txt"))]
    file
    "local"))

(defroutes app
  (GET "/status" request {:headers {"Content-type" "text/plain"} :body (get-revision)})
  (GET "/" request {:headers {"Content-type" "text/plain"} :body (xml/get-channels (get-tvdata))})
  (GET "/:id" [id :as request] {:headers {"Content-type" "text/plain"} :body (xml/get-programmes (get-tvdata) id)}))

(defn start-this-shop []
  (run-server app {:port 5000}))

(defn -main []
  (start-this-shop))<commit_msg>This should work inside uberjar<commit_after>
(ns notv.core
  (:gen-class)
  (:require [notv.render :as render]
            [notv.xml :as xml]
            [clojure.java.io :as io]
            [compojure.core :refer :all]
            [compojure.route :as route]
            [org.httpkit.server :refer [run-server]]))

;; tää kuuluis varmaan coreen
(defn get-tvdata-file-location []
  (let [env-path (System/getenv "TVDATA_FILE")]
    (if (empty? env-path)
      (io/file (io/resource "example-tvdata.xml"))
      env-path)))

(defn get-tvdata
  []
  (slurp (get-tvdata-file-location)))

(defn get-revision
  []
  (if-let [file (io/resource "gitrevision.txt")]
    (slurp file)
    "local"))

(defroutes app
  (GET "/status" request {:headers {"Content-type" "text/plain"} :body (get-revision)})
  (GET "/" request {:headers {"Content-type" "text/plain"} :body (xml/get-channels (get-tvdata))})
  (GET "/:id" [id :as request] {:headers {"Content-type" "text/plain"} :body (xml/get-programmes (get-tvdata) id)}))

(defn start-this-shop []
  (run-server app {:port 5000}))

(defn -main []
  (start-this-shop))
{'fraction_non_alphanumeric': 0.18824065633546036, 'fraction_numerical': 0.0036463081130355514, 'mean_word_length': 3.1104868913857677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '575932', 'n_tokens_mistral': 849, 'n_tokens_neox': 826, 'n_words': 187}