<commit_before>(ns clj-crud.main
  (:require [clojure.tools.logging :refer [info debug]]
            [com.stuartsierra.component :as component]
            [clj-crud.core :as core]
            [clj-crud.system.database :as database]
            [clojure.string :as string])
  (:gen-class))

(defn -main [& args]
  (info "Running main with args: " args)
  (let [port (Long/parseLong (first args))
        _ (assert (pos? port) (str "Something is wrong with the port argument: " (first args)))
        database-url (let [db-url (second args)]
                       (assert (.startsWith db-url "postgres:")
                               (str "Something is wrong with the database argument: " (second args)))
                       (database/db-url-for-heroku db-url))
        system (core/crud-system (core/production-config port database-url))]
    (component/start system)
    (.addShutdownHook (Runtime/getRuntime)
                      (Thread. (fn []
                                 (info "Shutting down main")
                                 (component/stop system))))))

(defn migrate [database-url]
  (assert (.startsWith "postgres:") "DATABASE_URL is required")
  (let [db-url (database/db-url-for-heroku database-url)]
    (-> (core/migration-system {:db-connect-string db-url})
        component/start
        component/stop)))<commit_msg>Get DATABASE_URL from env for migrate<commit_after>(ns clj-crud.main
  (:require [clojure.tools.logging :refer [info debug]]
            [com.stuartsierra.component :as component]
            [clj-crud.core :as core]
            [clj-crud.system.database :as database]
            [clojure.string :as string])
  (:gen-class))

(defn -main [& args]
  (info "Running main with args: " args)
  (let [port (Long/parseLong (first args))
        _ (assert (pos? port) (str "Something is wrong with the port argument: " (first args)))
        database-url (let [db-url (second args)]
                       (assert (.startsWith db-url "postgres:")
                               (str "Something is wrong with the database argument: " (second args)))
                       (database/db-url-for-heroku db-url))
        system (core/crud-system (core/production-config port database-url))]
    (component/start system)
    (.addShutdownHook (Runtime/getRuntime)
                      (Thread. (fn []
                                 (info "Shutting down main")
                                 (component/stop system))))))

(defn migrate []
  (let [db-url (System/getenv "DATABASE_URL")]
    (assert (.startsWith db-url "postgres:") "DATABASE_URL is required")
    (let [db-url (database/db-url-for-heroku database-url)]
      (-> (core/migration-system {:db-connect-string db-url})
          component/start
          component/stop))))
{'fraction_non_alphanumeric': 0.1324217344368478, 'fraction_numerical': 0.0, 'mean_word_length': 2.0854605993340734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3703972', 'n_tokens_mistral': 829, 'n_tokens_neox': 806, 'n_words': 214}