|
99 | 99 | (when-let [repos_cnt (:repositories_count v)] |
100 | 100 | (> repos_cnt 0))))))) |
101 | 101 |
|
102 | | -(defn- filter-repositories-in [repositories] |
103 | | - (->> repositories |
104 | | - (filter #(not-empty (:owner_url (val %)))))) |
105 | | - |
106 | | -(defn- filter-repositories-out [repositories] |
107 | | - (filter #(> (:a %) 0) repositories)) |
108 | | - |
109 | 102 | (def owners-keys-mapping |
110 | 103 | {:a :location |
111 | 104 | :au :icon_url |
|
125 | 118 | :s :followers}) |
126 | 119 |
|
127 | 120 | (defn- owners-as-map [owners & [full?]] |
128 | | - (-> (for [[_ {:keys [description repositories_count html_url icon_url name |
129 | | - pso_top_id_name login followers created_at floss_policy |
130 | | - ospo_url website forge email location pso]}] owners] |
131 | | - (conj |
132 | | - (let [short_desc (when (not-empty description) (shorten-string description))] |
133 | | - {:au icon_url |
134 | | - :d (if full? description short_desc) |
135 | | - :f floss_policy |
136 | | - :h website |
137 | | - :id html_url |
138 | | - :l login |
139 | | - :m pso_top_id_name |
140 | | - :n name |
141 | | - :os ospo_url |
142 | | - :ps pso |
143 | | - :r repositories_count |
144 | | - :s (or followers 0)}) |
145 | | - (when full? {:a location :e email :c created_at :p forge}))) |
146 | | - (replace-vals nil ""))) |
147 | | - |
148 | | -(defn- owners-to-map [& [full?]] |
149 | | - (-> @owners |
150 | | - filter-owners |
151 | | - (owners-as-map full?))) |
| 121 | + (as-> (filter (fn [[_ v]] |
| 122 | + (and (not-empty (:html_url v)) |
| 123 | + (when-let [repos_cnt (:repositories_count v)] |
| 124 | + (> repos_cnt 0)))) |
| 125 | + owners) owners |
| 126 | + (for [[_ {:keys [description repositories_count html_url icon_url name |
| 127 | + pso_top_id_name login followers created_at floss_policy |
| 128 | + ospo_url website forge email location pso]}] owners] |
| 129 | + (conj |
| 130 | + (let [short_desc (when (not-empty description) (shorten-string description))] |
| 131 | + {:au icon_url |
| 132 | + :d (if full? description short_desc) |
| 133 | + :f floss_policy |
| 134 | + :h website |
| 135 | + :id html_url |
| 136 | + :l login |
| 137 | + :m pso_top_id_name |
| 138 | + :n name |
| 139 | + :os ospo_url |
| 140 | + :ps pso |
| 141 | + :r repositories_count |
| 142 | + :s (or followers 0)}) |
| 143 | + (when full? {:a location :e email :c created_at :p forge}))) |
| 144 | + (replace-vals owners nil ""))) |
152 | 145 |
|
153 | 146 | (defn- owners-to-csv [] |
154 | | - (->> (owners-to-map :full) |
| 147 | + (->> (owners-as-map @owners :full) |
155 | 148 | (map #(set/rename-keys % owners-keys-mapping)) |
156 | 149 | maps-to-csv)) |
157 | 150 |
|
|
223 | 216 | :o :owner}) |
224 | 217 |
|
225 | 218 | (defn- repositories-as-map [repositories & [full?]] |
226 | | - (-> (for [[_ {:keys [metadata owner_url description full_name |
227 | | - updated_at fork template language html_url |
228 | | - license forks_count archived platform] |
229 | | - :as repo_data}] repositories] |
230 | | - (let [short_desc (when (not-empty description) (shorten-string description)) |
231 | | - repo_name (or (last (re-matches #".+/([^/]+)/?" full_name)) full_name) |
232 | | - files (:files metadata)] |
233 | | - (conj |
234 | | - {:a (compute-repository-awesome-score repo_data) |
235 | | - :a? (or archived false) |
236 | | - :c? (false? (empty? (:contributing files))) |
237 | | - :d (if full? description short_desc) |
238 | | - :f forks_count |
239 | | - :fn full_name |
240 | | - :f? (or fork false) |
241 | | - :l language |
242 | | - :li license |
243 | | - :n repo_name |
244 | | - :o (when-let [[_ host owner] |
245 | | - (re-matches |
246 | | - (re-pattern (str (:hosts urls) "/([^/]+)/owners/([^/]+)")) |
247 | | - owner_url)] |
248 | | - (let [host (if (= host "GitHub") "github.com" host)] |
249 | | - (str "https://" host "/" owner))) |
250 | | - :p platform |
251 | | - :p? (false? (empty? (:publiccode files))) |
252 | | - :t? (or template false) |
253 | | - :u updated_at} |
254 | | - (when full? {:id html_url})))) |
255 | | - (replace-vals nil ""))) |
256 | | - |
257 | | -(defn- repositories-to-map [& [full?]] |
258 | | - (-> @repositories |
259 | | - filter-repositories-in |
260 | | - (repositories-as-map full?) |
261 | | - filter-repositories-out)) |
| 219 | + (as-> (filter #(not-empty (:owner_url (val %))) repositories) repos |
| 220 | + (for [[_ {:keys [metadata owner_url description full_name |
| 221 | + updated_at fork template language html_url |
| 222 | + license forks_count archived platform] |
| 223 | + :as repo_data}] repos] |
| 224 | + (let [short_desc (when (not-empty description) (shorten-string description)) |
| 225 | + repo_name (or (last (re-matches #".+/([^/]+)/?" full_name)) full_name) |
| 226 | + files (:files metadata)] |
| 227 | + (conj |
| 228 | + {:a (compute-repository-awesome-score repo_data) |
| 229 | + :a? (or archived false) |
| 230 | + :c? (false? (empty? (:contributing files))) |
| 231 | + :d (if full? description short_desc) |
| 232 | + :f forks_count |
| 233 | + :fn full_name |
| 234 | + :f? (or fork false) |
| 235 | + :l language |
| 236 | + :li license |
| 237 | + :n repo_name |
| 238 | + :o (when-let [[_ host owner] |
| 239 | + (re-matches |
| 240 | + (re-pattern (str (:hosts urls) "/([^/]+)/owners/([^/]+)")) |
| 241 | + owner_url)] |
| 242 | + (let [host (if (= host "GitHub") "github.com" host)] |
| 243 | + (str "https://" host "/" owner))) |
| 244 | + :p platform |
| 245 | + :p? (false? (empty? (:publiccode files))) |
| 246 | + :t? (or template false) |
| 247 | + :u updated_at} |
| 248 | + (when full? {:id html_url})))) |
| 249 | + (if full? repos (filter #(> (:a %) 0) repos)) |
| 250 | + (replace-vals repos nil ""))) |
262 | 251 |
|
263 | 252 | (defn- repositories-to-csv [] |
264 | | - (->> (repositories-to-map :full) |
| 253 | + (->> (repositories-as-map @repositories :full) |
265 | 254 | (map #(set/rename-keys % repositories-keys-mapping)) |
266 | 255 | maps-to-csv)) |
267 | 256 |
|
|
482 | 471 | (spit "awesome.json"))) |
483 | 472 |
|
484 | 473 | (defn- output-owners-json [& [full?]] |
485 | | - (as-> (owners-to-map full?) o |
486 | | - (mapv identity o) |
487 | | - (if-not full? o (map #(set/rename-keys % owners-keys-mapping) o)) |
488 | | - (json/generate-string o) |
489 | | - (spit (if full? "codegouvfr-organizations.json" "owners.json") o))) |
| 474 | + (as-> (owners-as-map @owners full?) owners |
| 475 | + (mapv identity owners) |
| 476 | + (if-not full? owners (map #(set/rename-keys % owners-keys-mapping) owners)) |
| 477 | + (json/generate-string owners) |
| 478 | + (spit (if full? "codegouvfr-organizations.json" "owners.json") owners))) |
490 | 479 |
|
491 | 480 | (defn- output-owners-csv [] |
492 | 481 | (with-open [file (io/writer "codegouvfr-organizations.csv")] |
|
534 | 523 | (spit "latest-releases.xml"))) |
535 | 524 |
|
536 | 525 | (defn- output-repositories-json [& [full]] |
537 | | - (as-> (repositories-to-map full) r |
538 | | - (if-not full r (map #(set/rename-keys % repositories-keys-mapping) r)) |
539 | | - (json/generate-string r) |
540 | | - (spit (if full "codegouvfr-repositories.json" "repos_preprod.json") r))) |
| 526 | + (as-> (repositories-as-map @repositories full) repos |
| 527 | + (if-not full repos (map #(set/rename-keys % repositories-keys-mapping) repos)) |
| 528 | + (json/generate-string repos) |
| 529 | + (spit (if full "codegouvfr-repositories.json" "repos_preprod.json") repos))) |
541 | 530 |
|
542 | 531 | (defn- output-latest-repositories-xml [] |
543 | 532 | (->> @repositories |
|
613 | 602 | (let [lower (* (quot score 100) 100) |
614 | 603 | upper (+ lower 100)] |
615 | 604 | [lower upper])) |
616 | | - repos (repositories-to-map)] |
| 605 | + repos (repositories-as-map @repositories)] |
617 | 606 | (->> repos |
618 | 607 | (map :a) |
619 | 608 | (group-by score-range) |
|
725 | 714 | (defn- display-data! [] |
726 | 715 | (log/info "Hosts:" (count @hosts)) |
727 | 716 | (log/info "Owners:" (count @owners)) |
728 | | - (log/info "Owners (filtered):" (count (owners-to-map @owners))) |
| 717 | + (log/info "Owners (limited):" (count (owners-as-map @owners))) |
729 | 718 | (log/info "Repositories:" (count @repositories)) |
730 | | - (log/info "Repositories (filtered):" (count (repositories-to-map @repositories))) |
| 719 | + (log/info "Repositories (limited):" (count (repositories-as-map @repositories))) |
731 | 720 | (log/info "Awesome codegouvfr:" (count @awesome))) |
732 | 721 |
|
733 | 722 | ;; Main execution |
|
0 commit comments