diff options
| author | 2013-09-02 22:06:51 +0200 | |
|---|---|---|
| committer | 2013-09-02 22:06:51 +0200 | |
| commit | f855dbdca6e95ac367b7a9dae9d3a866e1f85d37 (patch) | |
| tree | b56089793ec4b41414f3e7574295684bae5170ff /app/models/Feed.php | |
| parent | 31a6a13268023a2db5eba2445ee6c7db4a6d9623 (diff) | |
SQL and model optimisation
Big effect (on speed and memory), but few changes :-)
Drastically reduced the number of SQL requests needed (from 233 down to
8 to load the home page with my own data set = 140 feeds in 15
categories).
Drastically reduced the amount of data transferred from MySQL to PHP.
Diffstat (limited to 'app/models/Feed.php')
| -rw-r--r-- | app/models/Feed.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/models/Feed.php b/app/models/Feed.php index 678809af6..e9e21f06a 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -4,6 +4,7 @@ class Feed extends Model { private $id = null; private $url; private $category = '000000'; + private $nbNotRead = -1; private $entries = null; private $name = ''; private $website = ''; @@ -82,8 +83,12 @@ class Feed extends Model { return $feedDAO->countEntries ($this->id ()); } public function nbNotRead () { + if ($this->nbNotRead < 0) { $feedDAO = new FeedDAO (); - return $feedDAO->countNotRead ($this->id ()); + $this->nbNotRead = $feedDAO->countNotRead ($this->id ()); + } + + return $this->nbNotRead; } public function favicon () { $file = '/data/favicons/' . $this->id () . '.ico'; @@ -162,6 +167,12 @@ class Feed extends Model { } $this->keep_history = $value; } + public function _nbNotRead ($value) { //Alex + if (!is_int (intval ($value))) { + $value = -1; + } + $this->nbNotRead = $value; + } public function load () { if (!is_null ($this->url)) { @@ -506,7 +517,9 @@ class HelperFeed { $list[$key]->_httpAuth (base64_decode ($dao['httpAuth'])); $list[$key]->_error ($dao['error']); $list[$key]->_keepHistory ($dao['keep_history']); - + if (isset ($dao['nbNotRead'])) { + $list[$key]->_nbNotRead ($dao['nbNotRead']); + } if (isset ($dao['id'])) { $list[$key]->_id ($dao['id']); } |
