зеркало из https://github.com/nextcloud/news.git
allow to turn of autopurge
This commit is contained in:
Родитель
1e6f862048
Коммит
7375daf213
|
@ -174,7 +174,7 @@ useCronUpdates = true
|
|||
|
||||
|
||||
* **autoPurgeMinimumInterval**: Minimum amount of seconds after deleted feeds and folders are removed from the database. Values below 60 seconds are ignored
|
||||
* **autoPurgeCount**: Defines the minimum amount of articles that can be unread per feed before they get deleted
|
||||
* **autoPurgeCount**: Defines the minimum amount of articles that can be unread per feed before they get deleted, a negative value will turn off deleting articles completely
|
||||
* **maxRedirects**: How many redirects the updater should follow
|
||||
* **feedFetcherTimeout**: Maximum number of seconds to wait for an RSS or Atom feed to load. If a feed takes longer than that number of seconds to update, the update will be aborted
|
||||
* **useCronUpdates**: To use a custom update/cron script you need to disable the cronjob which is run by ownCloud by default by setting this to false
|
||||
|
|
|
@ -24,7 +24,7 @@ use \OCA\News\Config\Config;
|
|||
class ItemService extends Service {
|
||||
|
||||
private $statusFlag;
|
||||
private $autoPurgeCount;
|
||||
private $config;
|
||||
private $timeFactory;
|
||||
private $itemMapper;
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ItemService extends Service {
|
|||
Config $config){
|
||||
parent::__construct($itemMapper);
|
||||
$this->statusFlag = $statusFlag;
|
||||
$this->autoPurgeCount = $config->getAutoPurgeCount();
|
||||
$this->config = $config;
|
||||
$this->timeFactory = $timeFactory;
|
||||
$this->itemMapper = $itemMapper;
|
||||
}
|
||||
|
@ -197,7 +197,10 @@ class ItemService extends Service {
|
|||
* old, the id is taken
|
||||
*/
|
||||
public function autoPurgeOld(){
|
||||
$this->itemMapper->deleteReadOlderThanThreshold($this->autoPurgeCount);
|
||||
$count = $this->config->getAutoPurgeCount();
|
||||
if ($count >= 0) {
|
||||
$this->itemMapper->deleteReadOlderThanThreshold($count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ style('news', 'admin');
|
|||
'Defines the maximum amount of articles that can be read per ' .
|
||||
"feed which won't be deleted by the cleanup job; ".
|
||||
'if old articles reappear after being read, increase ' .
|
||||
'this value'
|
||||
'this value; negative values will turn this feature off ' .
|
||||
'completely'
|
||||
)); ?></em>
|
||||
</p>
|
||||
<p><input type="text" name="news-auto-purge-count"
|
||||
|
|
|
@ -29,34 +29,31 @@ class ItemServiceTest extends \PHPUnit_Framework_TestCase {
|
|||
private $status;
|
||||
private $time;
|
||||
private $newestItemId;
|
||||
private $config;
|
||||
|
||||
|
||||
protected function setUp(){
|
||||
$this->time = 222;
|
||||
$timeFactory = $this->getMock('TimeFactory', ['getTime']);
|
||||
$timeFactory->expects($this->any())
|
||||
$this->timeFactory = $this->getMock('TimeFactory', ['getTime']);
|
||||
$this->timeFactory->expects($this->any())
|
||||
->method('getTime')
|
||||
->will($this->returnValue($this->time));
|
||||
$this->mapper = $this->getMockBuilder('\OCA\News\Db\ItemMapper')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$statusFlag = $this->getMockBuilder('\OCA\News\Db\StatusFlag')
|
||||
$this->statusFlag = $this->getMockBuilder('\OCA\News\Db\StatusFlag')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->status = StatusFlag::STARRED;
|
||||
$statusFlag->expects($this->any())
|
||||
$this->statusFlag->expects($this->any())
|
||||
->method('typeToStatus')
|
||||
->will($this->returnValue($this->status));
|
||||
$this->threshold = 2;
|
||||
$config = $this->getMockBuilder(
|
||||
$this->config = $this->getMockBuilder(
|
||||
'\OCA\News\Config\Config')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$config->expects($this->any())
|
||||
->method('getAutoPurgeCount')
|
||||
->will($this->returnValue($this->threshold));
|
||||
$this->itemService = new ItemService($this->mapper,
|
||||
$statusFlag, $timeFactory, $config);
|
||||
$this->statusFlag, $this->timeFactory, $this->config);
|
||||
$this->user = 'jack';
|
||||
$this->id = 3;
|
||||
$this->updatedSince = 20333;
|
||||
|
@ -356,9 +353,22 @@ class ItemServiceTest extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
|
||||
public function testAutoPurgeOldWillPurgeOld(){
|
||||
$this->config->expects($this->once())
|
||||
->method('getAutoPurgeCount')
|
||||
->will($this->returnValue(2));
|
||||
$this->mapper->expects($this->once())
|
||||
->method('deleteReadOlderThanThreshold')
|
||||
->with($this->equalTo($this->threshold));
|
||||
->with($this->equalTo(2));
|
||||
|
||||
$this->itemService->autoPurgeOld();
|
||||
}
|
||||
|
||||
public function testAutoPurgeOldWontPurgeOld(){
|
||||
$this->config->expects($this->once())
|
||||
->method('getAutoPurgeCount')
|
||||
->will($this->returnValue(-1));
|
||||
$this->mapper->expects($this->never())
|
||||
->method('deleteReadOlderThanThreshold');
|
||||
|
||||
$this->itemService->autoPurgeOld();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче