Skip to content

Commit dd64e82

Browse files
committed
src/consolidate-datacodegouvfr.clj: Output latest-[owners|repositories].xml
1 parent d301d31 commit dd64e82

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/consolidate-datacodegouvfr.clj

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
;; - spit tags.json for awesome software
99
;; - define and add an awesome-like score?
1010

11+
(deps/add-deps '{:deps {clj-rss/clj-rss {:mvn/version "0.4.0"}}})
12+
(require '[clj-rss.core :as rss])
13+
1114
;; Initialize atoms
1215
(def hosts (atom ()))
1316
(def forges (atom ()))
@@ -140,6 +143,26 @@
140143
json/generate-string
141144
(spit "owners.json"))
142145

146+
(defn toInst [^String s]
147+
(.toInstant (clojure.instant/read-instant-date s)))
148+
149+
(->> @owners
150+
(filter #(:created_at (val %)))
151+
(sort-by #(clojure.instant/read-instant-date (:created_at (val %))))
152+
reverse
153+
(take 10)
154+
(map (fn [[o o-data]]
155+
{:title (str "Nouveau compte dans code.gouv.fr : " (:name o-data))
156+
:link (:html_url o-data)
157+
:guid o
158+
:description (:description o-data)
159+
:pubDate (toInst (:created_at o-data))}))
160+
(rss/channel-xml
161+
{:title "code.gouv.fr/sources - Nouveaux comptes d'organisation"
162+
:link "https://code.gouv.fr/data/latest-repositories.xml"
163+
:description "code.gouv.fr/sources - Nouveaux comptes d'organisation"})
164+
(spit "latest-owners.xml"))
165+
143166
;; Spit repositories.json
144167
(->>
145168
@repositories
@@ -169,6 +192,24 @@
169192
json/generate-string
170193
(spit "repositories.json"))
171194

195+
(->> @repositories
196+
(filter #(:created_at (val %)))
197+
(sort-by #(clojure.instant/read-instant-date (:created_at (val %))))
198+
reverse
199+
(take 10)
200+
(map (fn [[r r-data]]
201+
(let [name (let [fn (:full_name r-data)] (or (last (re-matches #".+/([^/]+)/?" fn)) fn))]
202+
{:title (str "Nouveau dépôt de code source dans code.gouv.fr : " name)
203+
:link (:html_url r-data)
204+
:guid r
205+
:description (:description r-data)
206+
:pubDate (toInst (:created_at r-data))})))
207+
(rss/channel-xml
208+
{:title "code.gouv.fr/sources - Nouveaux dépôts de code source"
209+
:link "https://code.gouv.fr/data/latest-repositories.xml"
210+
:description "code.gouv.fr/sources - Nouveaux dépôts de code source"})
211+
(spit "latest-repositories.xml"))
212+
172213
;; Output platforms.csv
173214
(shell/sh "rm" "-f" "platforms.csv")
174215
(doseq [{:keys [name kind]} @hosts]

0 commit comments

Comments
 (0)