diff options
| author | 2013-11-12 18:22:41 +0100 | |
|---|---|---|
| committer | 2013-11-12 18:22:41 +0100 | |
| commit | 58cb842966f437a44f58644439f513b94f9dccac (patch) | |
| tree | 8c240fbca7b38c69f62c8f7a1607b8eb699e1af6 /app/controllers/indexController.php | |
| parent | fa92430b1f247ee335a9b8b553c2a622574cae08 (diff) | |
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
Diffstat (limited to 'app/controllers/indexController.php')
| -rwxr-xr-x | app/controllers/indexController.php | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 2f86034ee..e99ae2e44 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -2,7 +2,6 @@ class indexController extends ActionController { private $get = false; - private $nb_not_read = 0; private $nb_not_read_cat = 0; 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 (); $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); $this->view->cat_aside = $catDAO->listCategories (); $this->view->nb_favorites = $entryDAO->countUnreadReadFavorites (); - $this->view->nb_total = $entryDAO->count (); $this->view->currentName = ''; $this->view->get_c = ''; @@ -78,6 +70,12 @@ class indexController extends ActionController { $error = $this->checkAndProcessType ($type); // 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; View::prependTitle ( $this->view->currentName . @@ -166,8 +164,11 @@ class indexController extends ActionController { $this->view->get_c = $type['type']; return false; } elseif ($type['type'] == 'c') { - $catDAO = new CategoryDAO (); - $cat = $catDAO->searchById ($type['id']); + $cat = isset($this->view->cat_aside[$type['id']]) ? $this->view->cat_aside[$type['id']] : null; + if ($cat === null) { + $catDAO = new CategoryDAO (); + $cat = $catDAO->searchById ($type['id']); + } if ($cat) { $this->view->currentName = $cat->name (); $this->nb_not_read_cat = $cat->nbNotRead (); @@ -177,8 +178,11 @@ class indexController extends ActionController { return true; } } elseif ($type['type'] == 'f') { - $feedDAO = new FeedDAO (); - $feed = $feedDAO->searchById ($type['id']); + $feed = HelperCategory::findFeed($this->view->cat_aside, $type['id']); + if (empty($feed)) { + $feedDAO = new FeedDAO (); + $feed = $feedDAO->searchById ($type['id']); + } if ($feed) { $this->view->currentName = $feed->name (); $this->nb_not_read_cat = $feed->nbNotRead (); |
