<commit_before>(ns metabase.core
  (:gen-class)
  (:require [clojure.tools.logging :as log]
            [clojure.java.jdbc :as jdbc]
            [compojure.core :refer [context defroutes GET]]
            [compojure.route :as route]
            [ring.middleware.json :refer [wrap-json-response]]
            [ring.util.response :as resp]))

(defn liquibase-sql []
  (let [conn (jdbc/get-connection {:subprotocol "postgresql"
                                   :subname "//localhost:15432/corvus_test"
                                   :user "corvus"
                                   :password "<PASSWORD>"})]
    (com.metabase.corvus.migrations.LiquibaseMigrations/genSqlDatabase conn)))

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (liquibase-sql))

;; placeholder until we actually define real API routes
(defroutes api-routes
  ;; call /api/test to see this
  (GET "/test" [] {:status 200 :body {:message "We can serialize JSON <3"}}))

(defn serve-index "Serve index.html" [request]
  (resp/file-response "frontend_client/index.html"))

(defroutes routes
  (GET "/" [] serve-index)                            ; ^/$    -> index.html
  (context "/api" [] api-routes)                      ; ^/api/ -> API routes
  (route/files "/app/" {:root "frontend_client/app"}) ; ^/app/ -> static files under frontend_client/app
  (route/not-found serve-index))                      ; Anything else (e.g. /user/edit_current) should serve up index.html; Angular app will handle the rest

(def app
  "The primary entry point to the HTTP server"
  (-> routes
      wrap-json-response      ; middleware to automatically serialize suitable objects as JSON in responses
      ))<commit_msg>actually use `letfn` for `serve-index` to avoid introducing one-off fn<commit_after>(ns metabase.core
  (:gen-class)
  (:require [clojure.tools.logging :as log]
            [clojure.java.jdbc :as jdbc]
            [compojure.core :refer [context defroutes GET]]
            [compojure.route :as route]
            [ring.middleware.json :refer [wrap-json-response]]
            [ring.util.response :as resp]))

(defn liquibase-sql []
  (let [conn (jdbc/get-connection {:subprotocol "postgresql"
                                   :subname "//localhost:15432/corvus_test"
                                   :user "corvus"
                                   :password "<PASSWORD>"})]
    (com.metabase.corvus.migrations.LiquibaseMigrations/genSqlDatabase conn)))

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (liquibase-sql))

;; placeholder until we actually define real API routes
(defroutes api-routes
  ;; call /api/test to see this
  (GET "/test" [] {:status 200 :body {:message "We can serialize JSON <3"}}))

(letfn [(serve-index [_] (resp/file-response "frontend_client/index.html"))]
  (defroutes routes
    (GET "/" [] serve-index)                            ; ^/$    -> index.html
    (context "/api" [] api-routes)                      ; ^/api/ -> API routes
    (route/files "/app/" {:root "frontend_client/app"}) ; ^/app/ -> static files under frontend_client/app
    (route/not-found serve-index)))                     ; Anything else (e.g. /user/edit_current) should serve up index.html; Angular app will handle the rest

(def app
  "The primary entry point to the HTTP server"
  (-> routes
      wrap-json-response      ; middleware to automatically serialize suitable objects as JSON in responses
      ))
{'fraction_non_alphanumeric': 0.13094196558763488, 'fraction_numerical': 0.005249343832020997, 'mean_word_length': 2.226716839134525, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1267617', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1030, 'n_words': 288}