Suppression multiples requêtes count

Suppression de plusieurs requêtes count inutiles (genre
`$entryDAO->countNotRead()` avant un UPDATE), et suppression de
l'affichage du nombre d'articles total.
Corrige https://github.com/marienfressinaud/FreshRSS/issues/246
pull/279/head
Alexandre Alapetite 11 years ago
parent fa92430b1f
commit 58cb842966
  1. 4
      app/App_FrontController.php
  2. 20
      app/controllers/indexController.php
  3. 2
      app/i18n/en.php
  4. 2
      app/i18n/fr.php
  5. 2
      app/layout/aside_flux.phtml

@ -43,10 +43,6 @@ class App_FrontController extends FrontController {
private function loadParamsView () { private function loadParamsView () {
$this->conf = Session::param ('conf', new RSSConfiguration ()); $this->conf = Session::param ('conf', new RSSConfiguration ());
View::_param ('conf', $this->conf); View::_param ('conf', $this->conf);
$entryDAO = new EntryDAO ();
View::_param ('nb_not_read', $entryDAO->countNotRead ());
Session::_param ('language', $this->conf->language ()); Session::_param ('language', $this->conf->language ());
} }

@ -2,7 +2,6 @@
class indexController extends ActionController { class indexController extends ActionController {
private $get = false; private $get = false;
private $nb_not_read = 0;
private $nb_not_read_cat = 0; private $nb_not_read_cat = 0;
public function indexAction () { public function indexAction () {
@ -56,19 +55,12 @@ class indexController extends ActionController {
} }
} }
$nb_not_read = $this->view->nb_not_read;
if($nb_not_read > 0) {
View::appendTitle (' (' . $nb_not_read . ')');
}
View::prependTitle (' - ');
$entryDAO = new EntryDAO (); $entryDAO = new EntryDAO ();
$feedDAO = new FeedDAO (); $feedDAO = new FeedDAO ();
$catDAO = new CategoryDAO (); $catDAO = new CategoryDAO ();
$this->view->cat_aside = $catDAO->listCategories (); $this->view->cat_aside = $catDAO->listCategories ();
$this->view->nb_favorites = $entryDAO->countUnreadReadFavorites (); $this->view->nb_favorites = $entryDAO->countUnreadReadFavorites ();
$this->view->nb_total = $entryDAO->count ();
$this->view->currentName = ''; $this->view->currentName = '';
$this->view->get_c = ''; $this->view->get_c = '';
@ -78,6 +70,12 @@ class indexController extends ActionController {
$error = $this->checkAndProcessType ($type); $error = $this->checkAndProcessType ($type);
// mise à jour des titres // mise à jour des titres
$this->view->nb_not_read = HelperCategory::CountUnreads($this->view->cat_aside, 1);
if ($this->view->nb_not_read > 0) {
View::appendTitle (' (' . $this->view->nb_not_read . ')');
}
View::prependTitle (' - ');
$this->view->rss_title = $this->view->currentName . ' - ' . $this->view->rss_title; $this->view->rss_title = $this->view->currentName . ' - ' . $this->view->rss_title;
View::prependTitle ( View::prependTitle (
$this->view->currentName . $this->view->currentName .
@ -166,8 +164,11 @@ class indexController extends ActionController {
$this->view->get_c = $type['type']; $this->view->get_c = $type['type'];
return false; return false;
} elseif ($type['type'] == 'c') { } elseif ($type['type'] == 'c') {
$cat = isset($this->view->cat_aside[$type['id']]) ? $this->view->cat_aside[$type['id']] : null;
if ($cat === null) {
$catDAO = new CategoryDAO (); $catDAO = new CategoryDAO ();
$cat = $catDAO->searchById ($type['id']); $cat = $catDAO->searchById ($type['id']);
}
if ($cat) { if ($cat) {
$this->view->currentName = $cat->name (); $this->view->currentName = $cat->name ();
$this->nb_not_read_cat = $cat->nbNotRead (); $this->nb_not_read_cat = $cat->nbNotRead ();
@ -177,8 +178,11 @@ class indexController extends ActionController {
return true; return true;
} }
} elseif ($type['type'] == 'f') { } elseif ($type['type'] == 'f') {
$feed = HelperCategory::findFeed($this->view->cat_aside, $type['id']);
if (empty($feed)) {
$feedDAO = new FeedDAO (); $feedDAO = new FeedDAO ();
$feed = $feedDAO->searchById ($type['id']); $feed = $feedDAO->searchById ($type['id']);
}
if ($feed) { if ($feed) {
$this->view->currentName = $feed->name (); $this->view->currentName = $feed->name ();
$this->nb_not_read_cat = $feed->nbNotRead (); $this->nb_not_read_cat = $feed->nbNotRead ();

@ -19,7 +19,7 @@ return array (
'import_export_opml' => 'Import / export (OPML)', 'import_export_opml' => 'Import / export (OPML)',
'subscription_management' => 'Subscriptions management', 'subscription_management' => 'Subscriptions management',
'all_feeds' => 'Main stream (%d)', 'all_feeds' => 'Main stream',
'favorite_feeds' => 'Favourites (%d)', 'favorite_feeds' => 'Favourites (%d)',
'not_read' => '%d unread', 'not_read' => '%d unread',
'not_reads' => '%d unread', 'not_reads' => '%d unread',

@ -19,7 +19,7 @@ return array (
'import_export_opml' => 'Importer / exporter (OPML)', 'import_export_opml' => 'Importer / exporter (OPML)',
'subscription_management' => 'Gestion des abonnements', 'subscription_management' => 'Gestion des abonnements',
'all_feeds' => 'Flux principal (%d)', 'all_feeds' => 'Flux principal',
'favorite_feeds' => 'Favoris (%d)', 'favorite_feeds' => 'Favoris (%d)',
'not_read' => '%d non lu', 'not_read' => '%d non lu',
'not_reads' => '%d non lus', 'not_reads' => '%d non lus',

@ -15,7 +15,7 @@
<div class="category all"> <div class="category all">
<a data-unread="<?php echo $this->nb_not_read; ?>" class="btn<?php echo $this->get_c == 'all' ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index'); ?>"> <a data-unread="<?php echo $this->nb_not_read; ?>" class="btn<?php echo $this->get_c == 'all' ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index'); ?>">
<i class="icon i_all"></i> <i class="icon i_all"></i>
<?php echo Translate::t ('all_feeds', $this->nb_total); ?> <?php echo Translate::t ('all_feeds'); ?>
</a> </a>
</div> </div>
</li> </li>

Loading…
Cancel
Save