Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
(ns versions.analyze
(:require [ :as csv]
[ :as io]
[clojure.string :as string]
[plumbing.core :refer [fnk defnk]]
[plumbing.graph :as graph]
[versions.scrape :as scrape]))
(defn has-deps? [repo]
(not (nil? (:deps repo))))
(defn get-clojure-version [repo]
(get-in repo [:deps 'org.clojure/clojure :mvn/version]))
(defn released-clojure-version [v]
(when (string? v)
(if (re-matches #"^(\d)+\.(\d)+\.(\d)+$" v) v "other")))
(defn get-released-clojure-version [v]
(released-clojure-version (get-clojure-version v)))
(defn dataset->csv [x]
(let [columns (keys (first x))]
(into [(mapv name columns)]
(for [row x]
(mapv #(get row %) columns)))))
(defn version->vector [v]
(when v
(mapv #(Long/parseLong %) (string/split v #"\."))))
(defn compare-versions [v1 v2]
(cond (and (= v1 "other") (= v2 "other")) 0
(= v1 "other") 1
(= v2 "other") -1
:otherwise (compare (version->vector v1) (version->vector v2))))
(defn has-clojure-in-profiles? [{:keys [profile-deps]}]
(some #(contains? % 'org.clojure/clojure) (vals profile-deps)))
(def g
(fnk []
(fnk [raw-repos]
(filter :unparsable raw-repos))
(fnk [raw-repos]
(remove :unparsable raw-repos))
(fnk [repos]
(remove has-deps? repos))
(fnk [repos]
(filter has-deps? repos))
(fnk [repos]
(remove #(get-in % [:deps 'org.clojure/clojure]) repos))
(fnk [repos-without-clojure]
(filter has-clojure-in-profiles? repos-without-clojure))
(fnk [repos-without-clojure]
(remove has-clojure-in-profiles? repos-without-clojure))
(fnk [repos]
(group-by :full-name repos))
(fnk [repos-by-name]
(->> repos-by-name
(filter (fn [[k v]] (= (count v) 2)))
(map first)
(fnk [repos-without-deps doubles]
(remove #(contains? doubles (:full-name %))
(fnk [repos]
(frequencies (map :deps-type repos)))
(fnk [repos]
(frequencies (map get-released-clojure-version repos)))
(fnk [repos]
(->> (frequencies (map (juxt :deps-type get-released-clojure-version) repos))
(map (fn [[[deps-type version] count]]
{:deps-type (name deps-type)
:version version
:count count}))
(sort-by :version compare-versions)))
(fnk [repos-with-deps]
(frequencies (map (juxt :deps-type #(get-in % [:deps 'org.clojure/clojure :scope])) repos-with-deps)))
(fnk [clojure-versions-by-deps-type]
(->> clojure-versions-by-deps-type
(remove :version)
(map (juxt (comp keyword :deps-type) :count))
(into {})))
(fnk [number-of-projects-not-depending-on-clojure repos-count-by-deps-type]
(into {}
(for [k (keys number-of-projects-not-depending-on-clojure)]
[k (double
(/ (number-of-projects-not-depending-on-clojure k)
(repos-count-by-deps-type k)))])))
(fnk [repos]
(distinct (mapcat #(keys (second %)) (mapcat :deps repos))))})
(defn main []
(let [res ((graph/lazy-compile g) {})]
(with-open [w (io/writer "graph1.csv")]
(csv/write-csv w (dataset->csv (:clojure-versions-by-deps-type res))))