Commits

Cédric Bonhomme committed 12d6ce8

Sort articles for the page /inactives.

Comments (0)

Files changed (1)

pyaggr3g470r/views.py

     today = datetime.datetime.now()
     inactives = []
     for feed in user.feeds:
-        last_post = feed.articles[0].date
+        last_post = sorted(feed.articles, key=lambda t: t.date,
+reverse=True)[0].date
         elapsed = today - last_post
         if elapsed > datetime.timedelta(days=nb_days):
             inactives.append((feed, elapsed))
             # delete the feed (EmbeddedDocument object)
             user.feeds.remove(feed)
             user.save()
-            return redirect(url_for('home'))
+            return redirect(url_for('home'))