<commit_before>(ns chronograph.main
  (:require [chronograph.data :as data]
            [chronograph.db :as db]
            [chronograph.import.mdapi :as mdapi]
            [chronograph.import.laskuri :as laskuri]
            [chronograph.import.resolver :as resolver]
            [chronograph.import.first-deposit :as first-deposit])
  (:require [clojure.java.io :refer [reader]])
  (:require [clojure.edn :as edn])
  (:require [clj-time.format :as format]))

(defn -main
  [& args]
  
  (data/init!)
      
  (when (= (first args) "import-first-deposit")
      (prn "DOI first deposit dates")
      (first-deposit/run (second args)))
  
  (when (= (first args) "update-member-domains")
      (prn "update-member-domains")
      (mdapi/update-member-domains))
  
  (when (= (first args) "import-ever")
      (prn "DOI import everything ever")
      (mdapi/get-dois-updated-since nil))
  
  (when (= (first args) "new-updates")
      (prn "DOI import new updates")
      (mdapi/run-doi-extraction-new-updates))
  
  (when (= (first args) "resolve")
      (prn "DOI Resolution")
      (resolver/run-doi-resolution))
  
  (when (= (first args) "import-laskuri")
    (prn "Import local Laskuri data grouped by DOI")
    (laskuri/run-local-grouped (second args))))  <commit_msg>Removed ring in favour of using http-kit server (namespace reloading was problematic with the types-by-id atom). Also added functions for REPL.<commit_after>(ns chronograph.main
  (:require [chronograph.data :as data]
            [chronograph.db :as db]
            [chronograph.import.mdapi :as mdapi]
            [chronograph.handlers :as handlers]
            [chronograph.import.laskuri :as laskuri]
            [chronograph.import.resolver :as resolver]
            [chronograph.import.first-deposit :as first-deposit])
  (:require [clojure.java.io :refer [reader]])
  (:require [clojure.edn :as edn])
  (:require [org.httpkit.server :as server])
  (:require [clj-time.format :as format])
  (:require [crossref.util.config :refer [config]]))

(defn -main
  [& args]
  
  (data/init!)
      
  (when (= (first args) "import-first-deposit")
      (prn "DOI first deposit dates")
      (first-deposit/run (second args)))
  
  (when (= (first args) "update-member-domains")
      (prn "update-member-domains")
      (mdapi/update-member-domains))
  
  (when (= (first args) "import-ever")
      (prn "DOI import everything ever")
      (mdapi/get-dois-updated-since nil))
  
  (when (= (first args) "new-updates")
      (prn "DOI import new updates")
      (mdapi/run-doi-extraction-new-updates))
  
  (when (= (first args) "resolve")
      (prn "DOI Resolution")
      (resolver/run-doi-resolution))
  
  (when (= (first args) "import-laskuri")
    (prn "Import local Laskuri data grouped by DOI")
    (laskuri/run-local-grouped (second args)))
  
  (when (= (first args) "server")
    (prn "Server")
    (server/run-server handlers/app {:port (:port config)})))  


; For use in REPL.
(defonce s (atom nil))

(defn stop-server
  []
  (@s)
  (reset! s nil)
  (prn "Stop Server" @s)
  )

(defn start-server []
  (data/init!)
  (reset! s (server/run-server #'handlers/app {:port (:port config)}))
  (prn "Start Server" @s))

(defn restart-server []
  (stop-server)
  (start-server))
{'fraction_non_alphanumeric': 0.15663390663390664, 'fraction_numerical': 0.0, 'mean_word_length': 2.9146634615384617, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7215249', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1129, 'n_words': 278}