Date minimum pour afficher les articles

Implémente décision
https://github.com/marienfressinaud/FreshRSS/issues/323
This commit is contained in:
Alexandre Alapetite committed 2013-12-15 04:07:12 +01:00
1 parent 83e8c68b6f
commit 7e64cda415
3 files changed
+14 -7

No files matched your search

+5 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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) {