4
0
Эх сурвалжийг харах

Date minimum pour afficher les articles

Implémente décision
https://github.com/marienfressinaud/FreshRSS/issues/323
Alexandre Alapetite 12 жил өмнө
parent
commit
7e64cda415

+ 5 - 2
app/Models/EntryDAO.php

@@ -259,7 +259,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 		return isset ($entries[0]) ? $entries[0] : false;
 	}
 
-	public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = -1, $filter = '') {
+	public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) {
 		$where = '';
 		$values = array();
 		switch ($type) {
@@ -299,9 +299,12 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 			default:
 				throw new FreshRSS_EntriesGetter_Exception ('Bad order in Entry->listByType: [' . $order . ']!');
 		}
-		if ($firstId > 0) {
+		if ($firstId !== '') {
 			$where .= 'AND e.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' ';
 		}
+		if ($date_min > 0) {
+			$where .= 'AND e.id >= ' . $date_min . '000000 ';
+		}
 		$terms = array_unique(explode(' ', trim($filter)));
 		sort($terms);	//Put #tags first
 		$having = '';

+ 3 - 3
app/controllers/feedController.php

@@ -96,7 +96,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 
 						// on calcule la date des articles les plus anciens qu'on accepte
 						$nb_month_old = $this->view->conf->oldEntries ();
-						$date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);
+						$date_min = time () - (3600 * 24 * 30 * $nb_month_old);
 
 						$transactionStarted = true;
 						$feedDAO->beginTransaction ();
@@ -196,7 +196,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 
 		// on calcule la date des articles les plus anciens qu'on accepte
 		$nb_month_old = $this->view->conf->oldEntries ();
-		$date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);
+		$date_min = time () - (3600 * 24 * 30 * $nb_month_old);
 
 		$i = 0;
 		$flux_update = 0;
@@ -310,7 +310,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 
 		// on calcule la date des articles les plus anciens qu'on accepte
 		$nb_month_old = $this->view->conf->oldEntries ();
-		$date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);
+		$date_min = time () - (3600 * 24 * 30 * $nb_month_old);
 
 		// la variable $error permet de savoir si une erreur est survenue
 		// Le but est de ne pas arrêter l'import même en cas d'erreur

+ 6 - 2
app/controllers/indexController.php

@@ -124,15 +124,19 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 			}
 		}
 
+		// on calcule la date des articles les plus anciens qu'on affiche
+		$nb_month_old = $this->view->conf->oldEntries ();
+		$date_min = time () - (3600 * 24 * 30 * $nb_month_old);
+
 		try {
-			$entries = $this->entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter);
+			$entries = $this->entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter, $date_min);
 
 			// Si on a récupéré aucun article "non lus"
 			// on essaye de récupérer tous les articles
 			if ($state === 'not_read' && empty($entries)) {	//TODO: Remove in v0.8
 				Minz_Log::record ('Conflicting information about nbNotRead!', Minz_Log::DEBUG);
 				$this->view->state = 'all';
-				$entries = $this->entryDAO->listWhere($getType, $getId, 'all', $order, $nb, $first, $filter);
+				$entries = $this->entryDAO->listWhere($getType, $getId, 'all', $order, $nb, $first, $filter, $date_min);
 			}
 
 			if (count($entries) <= $nb) {