Просмотр исходного кода

Merge pull request #1517 from gsongsong/cli-act-num-articles

actualizeFeed return number of new articles as 3rd
Alexandre Alapetite 9 лет назад
Родитель
Сommit
2c0f5ff194
4 измененных файлов с 8 добавлено и 5 удалено
  1. 1 0
      CREDITS.md
  2. 4 2
      app/Controllers/feedController.php
  3. 2 2
      cli/actualize-user.php
  4. 1 1
      p/api/pshb.php

+ 1 - 0
CREDITS.md

@@ -17,6 +17,7 @@ People are sorted by name so please keep this order.
 * [dswd](https://github.com/dswd): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:dswd)
 * [ealdraed](https://github.com/ealdraed): [contributions](https://github.com/FreshRSS/FreshRSS/commits?author=ealdraed)
 * [Frans de Jonge](https://github.com/Frenzie): [contributions](https://github.com/FreshRSS/FreshRSS/commits?author=Frenzie), [Web](http://fransdejonge.com/)
+* [gsongsong](https://github.com/gsongsong): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:gsongsong)
 * [Guillaume Fillon](https://github.com/kokaz): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:kokaz), [Web](http://www.guillaume-fillon.com/)
 * [Guillaume Hayot](https://github.com/postblue): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:postblue), [Web](https://postblue.info/)
 * [hckweb](https://github.com/hckweb): [contributions](https://github.com/FreshRSS/FreshRSS/commits?author=hckweb)

+ 4 - 2
app/Controllers/feedController.php

@@ -254,6 +254,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 		$pshbMinAge = time() - (3600 * 24);  //TODO: Make a configuration.
 
 		$updated_feeds = 0;
+		$nb_new_articles = 0;
 		$is_read = FreshRSS_Context::$user_conf->mark_when['reception'] ? 1 : 0;
 		foreach ($feeds as $feed) {
 			$url = $feed->url();	//For detection of HTTP 301
@@ -374,6 +375,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 							$entryDAO->beginTransaction();
 						}
 						$entryDAO->addEntry($entry->toArray());
+						$nb_new_articles++;
 					}
 				}
 				$entryDAO->updateLastSeen($feed->id(), $oldGuids, $mtime);
@@ -450,7 +452,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 				$entryDAO->commit();
 			}
 		}
-		return array($updated_feeds, reset($feeds));
+		return array($updated_feeds, reset($feeds), $nb_new_articles);
 	}
 
 	/**
@@ -480,7 +482,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 			$feedDAO->updateCachedValues();
 			$entryDAO->commit();
 		} else {
-			list($updated_feeds, $feed) = self::actualizeFeed($id, $url, $force, null, false, $noCommit);
+			list($updated_feeds, $feed, $nb_new_articles) = self::actualizeFeed($id, $url, $force, null, false, $noCommit);
 		}
 
 		if (Minz_Request::param('ajax')) {

+ 2 - 2
cli/actualize-user.php

@@ -14,9 +14,9 @@ $username = cliInitUser($options['user']);
 
 fwrite(STDERR, 'FreshRSS actualizing user “' . $username . "”…\n");
 
-list($nbUpdatedFeeds, $feed) = FreshRSS_feed_Controller::actualizeFeed(0, '', true);
+list($nbUpdatedFeeds, $feed, $nbNewArticles) = FreshRSS_feed_Controller::actualizeFeed(0, '', true);
 
-echo "FreshRSS actualized $nbUpdatedFeeds feeds for $username\n";
+echo "FreshRSS actualized $nbUpdatedFeeds feeds for $username ($nbNewArticles new articles)\n";
 
 invalidateHttpCache($username);
 

+ 1 - 1
p/api/pshb.php

@@ -136,7 +136,7 @@ foreach ($users as $userFilename) {
 		                             join_path(USERS_PATH, '_', 'config.default.php'));
 		new Minz_ModelPdo($username);	//TODO: FIXME: Quick-fix while waiting for a better FreshRSS() constructor/init
 		FreshRSS_Context::init();
-		list($updated_feeds, $feed) = FreshRSS_feed_Controller::actualizeFeed(0, $self, false, $simplePie);
+		list($updated_feeds, $feed, $nb_new_articles) = FreshRSS_feed_Controller::actualizeFeed(0, $self, false, $simplePie);
 		if ($updated_feeds > 0 || $feed != false) {
 			$nb++;
 		} else {