 
 (defn get-repositories
   [url]
-  (-> (parse-json-body (http/get url)) :hits :hits))
+  (parse-json-body (http/get url)))
 
 (defn repository-id
   [r]
-  (:_id r))
+  (:id r))
 
 (defn repository-git-url
   [r]
-  (-> r :_source :url))
+  (-> r :url))
 
 (defn project-metrics
   [project]

  
(defn snapshot-repository
  [repo]
  (let [id        (repository-id repo)
        url       (repository-git-url repo)
        local-dir (canonical-path (string/join "/" ["/Volumes/data-drive/workspace" id]))
        name      (-> repo :_source :project :name)]
    (log/info "snapshotting " id name "from " url "to " local-dir)
    (if (directory? local-dir) (git-pull url local-dir) (git-clone url local-dir))
    (let [loc-data      (cloc/loc-collector (fn [a] a) local-dir "foo")
          snapshot-data (create-snapshot (-> repo :_source :project) (loc-metrics loc-data))]
      (log/info "snapshot " (put-snapshot snapshot-data id)))))

(defn -main
  [& args]
  (log/info "Kuona Snapshot Collector")
  
  (let [options          (parse-opts args cli-options)
        ;config-file      (:config (:options options))
        ;config           (load-config (file-reader config-file))
        repositories     (get-repositories "http://dashboard.kuona.io/api/repositories")
        urls             (map #(-> % :url) repositories)]
    (log/info "Found " (count repositories) " configured repositories for analysis")
    (doall (map snapshot-repository repositories))))

            [clj-jgit.querying :as git-query]
            [clojure.java.shell :as shell]
            [cheshire.core :refer :all]
            [slingshot.slingshot :refer :all]
            [kuona-core.metric.store :as store]
            [kuona-core.git :refer :all]
            [kuona-core.util :refer :all]
