Commits

Cédric Bonhomme  committed 37a380a

Performance imporvement (loading of the management page).

  • Participants
  • Parent commits 32b3c2e

Comments (0)

Files changed (1)

File pyaggr3g470r/views.py

         else:
             flash(gettext('File not allowed.'), 'danger')
 
-
     form = AddFeedForm()
-    #user = User.query.filter(User.id == g.user.id).first()
     nb_feeds = len(g.user.feeds.all())
-    nb_articles = len(Article.query.filter(Article.user_id == g.user.id).all())
-    nb_unread_articles = len(Article.query.filter(Article.user_id == g.user.id, Article.readed == False).all())
-    return render_template('management.html', user=g.user, form=form, \
-                            nb_feeds=nb_feeds, nb_articles=nb_articles, nb_unread_articles=nb_unread_articles, \
+    articles = Article.query.filter(Article.user_id == g.user.id)
+    nb_articles = articles.count()
+    nb_unread_articles = articles.filter(Article.readed == False).count()
+    return render_template('management.html', user=g.user, form=form,
+                            nb_feeds=nb_feeds, nb_articles=nb_articles, nb_unread_articles=nb_unread_articles,
                             not_on_heroku = not conf.ON_HEROKU)
 
 @app.route('/history', methods=['GET'])