<commit_before>(ns build-monitor-clj.app
  (:require [compojure.route :as route]
            [compojure.handler :as handler]
            [ring.adapter.jetty :as jetty]
            [build-monitor-clj.parser :as parser]
            [build-monitor-clj.reducer :as reducer]
            [cheshire.core :refer [generate-string]]
            [environ.core :refer [env]]
            [build-monitor-clj.config :refer :all]
            [compojure.core :refer :all])
  (:gen-class))

(defn- as-json-response [body]
  {:content-type "application/json"
   :body         (generate-string body)})

(defroutes main-routes
           (GET "/" [] (clojure.java.io/resource "public/index.html"))
           (GET "/all" [] (-> (parser/get-projects (cctray-url))
                              (reducer/aggregate)
                              (as-json-response)))
           (GET "/interesting" [] (-> (parser/get-interesting-projects (cctray-url))
                                      (reducer/show-selected-projects)
                                      (as-json-response)))
           (route/resources "/"))

(def app
  (handler/site main-routes))

(defn -main []
  (jetty/run-jetty app {:port (port) :join? false}))<commit_msg>Ste/Joe - Add an endpoint for getting all projects from user provided url<commit_after>(ns build-monitor-clj.app
  (:require [compojure.route :as route]
            [compojure.handler :as handler]
            [ring.adapter.jetty :as jetty]
            [build-monitor-clj.parser :as parser]
            [build-monitor-clj.reducer :as reducer]
            [cheshire.core :refer [generate-string]]
            [environ.core :refer [env]]
            [build-monitor-clj.config :refer :all]
            [compojure.core :refer :all])
  (:gen-class))

(defn- as-json-response [body]
  {:content-type "application/json"
   :body         (generate-string body)})

(defn get-json-projects [url]
  (-> (parser/get-projects url)
      (reducer/aggregate)
      (as-json-response)))

(defroutes main-routes
           (GET "/" [] (clojure.java.io/resource "public/index.html"))
           (GET "/api/projects" {params :params} (get-json-projects (:url params)))
           (GET "/all" [] (get-json-projects (cctray-url)))
           (GET "/interesting" [] (-> (parser/get-interesting-projects (cctray-url))
                                      (reducer/show-selected-projects)
                                      (as-json-response)))
           (route/resources "/"))

(def app
  (handler/site main-routes))


(defn -main []
  (jetty/run-jetty app {:port (port) :join? false}))
{'fraction_non_alphanumeric': 0.1527723924001551, 'fraction_numerical': 0.0, 'mean_word_length': 1.9452054794520548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2242624', 'n_tokens_mistral': 813, 'n_tokens_neox': 801, 'n_words': 160}