Browse Source

Rafraîchit uniquement les flux qui n'ont pas déjà été rafraîchis récemment

Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351
Alexandre Alapetite 12 years ago
parent
commit
06abbd02c2
2 changed files with 6 additions and 3 deletions
  1. 1 1
      app/Controllers/javascriptController.php
  2. 5 2
      app/Models/FeedDAO.php

+ 1 - 1
app/Controllers/javascriptController.php

@@ -8,7 +8,7 @@ class FreshRSS_javascript_Controller extends Minz_ActionController {
 	public function actualizeAction () {
 		header('Content-Type: text/javascript; charset=UTF-8');
 		$feedDAO = new FreshRSS_FeedDAO ();
-		$this->view->feeds = $feedDAO->listFeeds ();
+		$this->view->feeds = $feedDAO->listFeedsOrderUpdate();
 	}
 
 	public function nbUnreadsPerFeedAction() {

+ 5 - 2
app/Models/FeedDAO.php

@@ -198,8 +198,11 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		return self::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC));
 	}
 
-	public function listFeedsOrderUpdate () {
-		$sql = 'SELECT id, name, url, lastUpdate, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate';
+	public function listFeedsOrderUpdate ($cacheDuration = 1500) {
+		$sql = 'SELECT id, name, url, lastUpdate, pathEntries, httpAuth, keep_history '
+		     . 'FROM `' . $this->prefix . 'feed` '
+		     . 'WHERE lastUpdate < ' . (time() - intval($cacheDuration))
+		     . ' ORDER BY lastUpdate';
 		$stm = $this->bd->prepare ($sql);
 		$stm->execute ();