Fix nul date

This commit is contained in:
Andros Fenollosa 2021-07-18 12:50:54 +02:00
parent 1e9fd086c0
commit 03447a2f8c
2 changed files with 22 additions and 11 deletions

View File

@ -4,12 +4,11 @@ theme: light
# Options: daily, yesterday, weekly or all # Options: daily, yesterday, weekly or all
edition: weekly edition: weekly
feeds: feeds:
- https://github.com/clockworkpi/launcher/releases.atom
- https://programadorwebvalencia.com/feed/index.xml - https://programadorwebvalencia.com/feed/index.xml
- http://planet.es.python.org/rss.xml - http://planet.es.python.org/rss.xml
- https://diarioestoico.com/feed/ - https://diarioestoico.com/feed/
- https://republicaweb.es/feed/podcast - https://republicaweb.es/feed/podcast
old:
- https://static.fsf.org/fsforg/rss/news.xml - https://static.fsf.org/fsforg/rss/news.xml
- https://hakibenita.com/feeds/all.atom.xml - https://hakibenita.com/feeds/all.atom.xml
- https://www.blogger.com/feeds/5402814408460261521/posts/default - https://www.blogger.com/feeds/5402814408460261521/posts/default
@ -20,7 +19,6 @@ old:
- https://twobithistory.org/feed.xml - https://twobithistory.org/feed.xml
- https://nosinmiscookies.com/feed/ - https://nosinmiscookies.com/feed/
- http://planet.es.python.org/rss.xml - http://planet.es.python.org/rss.xml
- https://github.com/clockworkpi/launcher/releases.atom
- https://programadorwebvalencia.com/feed/index.xml - https://programadorwebvalencia.com/feed/index.xml
- https://ondahostil.wordpress.com/feed/ - https://ondahostil.wordpress.com/feed/
- http://neofronteras.com/?feed=rss2 - http://neofronteras.com/?feed=rss2

View File

@ -20,8 +20,8 @@
(let [daily (c/to-long (t/minus (t/now) (t/days 1))) (let [daily (c/to-long (t/minus (t/now) (t/days 1)))
weekly (c/to-long (t/minus (t/now) (t/weeks 1)))] weekly (c/to-long (t/minus (t/now) (t/weeks 1)))]
(case (:edition config) (case (:edition config)
"daily" (filter (fn [article] (>= (:published-date article) daily)) articles) "daily" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) daily))) articles)
"weekly" (filter (fn [article] (>= (:published-date article) weekly)) articles) "weekly" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) weekly))) articles)
:else articles))) :else articles)))
@ -49,17 +49,30 @@
) articles)) ) articles))
(defn order-published
[articles]
(reverse (sort-by :published-date articles)))
(defn get-articles (defn get-articles
[] []
;; Get all feeds from config -> feeds ;; Get all feeds from config -> feeds
(reverse (sort-by :published-date (-> (->
(reduce (reduce
(fn [feeds feed-url] (fn [feeds feed-url]
(conj feeds ; Read feed
(parse-url feed-url {:insecure? true :throw-exceptions false})) (let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})]
) [] (:feeds config)) ; Check is not null
(if (not (nil? feed))
; Add feed
(conj feeds feed)
; Alert fail
(prn (str "Error with '" feed-url) "'"))))
[] (:feeds config))
zip-feeds-in-articles zip-feeds-in-articles
datetimes-to-unixtime datetimes-to-unixtime
filter-edition filter-edition
order-published
add-cover-article add-cover-article
add-datetimes-formatter)))) add-datetimes-formatter
))