0013028: add failcount to scheduled import filter
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 12 Dec 2016 11:22:22 +0000 (12:22 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 17 May 2017 13:45:28 +0000 (15:45 +0200)
https://forge.tine20.org/view.php?id=13028

Change-Id: I4d41711b28b3eff2918de664526d2f7dedcb83d7
Reviewed-on: http://gerrit.tine20.com/customers/3945
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Tinebase/ScheduledImportTest.php
tine20/Tinebase/Controller/ScheduledImport.php
tine20/Tinebase/Model/ImportFilter.php

index e7193a0..47ff341 100644 (file)
@@ -80,6 +80,7 @@ class Tinebase_ScheduledImportTest extends TestCase
         $this->_uit->runNextScheduledImport();
 
         $all = $cc->search($filter);
+        self::assertGreaterThan(0, count($all));
         $seq = $all->getFirstRecord()->seq;
 
         // assert all events have been imported
@@ -94,8 +95,8 @@ class Tinebase_ScheduledImportTest extends TestCase
         $this->_uit->doScheduledImport($record);
 
         $all = $cc->search($filter);
-        $this->assertEquals(1, $all->count());
-        $this->assertGreaterThan($seq, $all->getFirstRecord()->seq);
+        self::assertEquals(1, $all->count());
+        self::assertGreaterThan($seq, $all->getFirstRecord()->seq);
     }
 
     /**
index b199eac..04624fd 100644 (file)
@@ -91,9 +91,8 @@ class Tinebase_Controller_ScheduledImport extends Tinebase_Controller_Record_Abs
         $aWeekAgo = clone $now;
         $aWeekAgo->subWeek(1);
 
-        $filter = new Tinebase_Model_ImportFilter(array(array(
-                array('field' => 'failcount', 'operator' => 'greater', 'value' => 5),
-            ),
+        $filter = new Tinebase_Model_ImportFilter(array(
+            array('field' => 'failcount', 'operator' => 'less', 'value' => self::MAXFAILCOUNT + 1),
             array(
             'condition' => 'OR', 'filters' => array(
                 array('field' => 'timestamp', 'operator' => 'isnull', 'value' => null),
@@ -140,8 +139,6 @@ class Tinebase_Controller_ScheduledImport extends Tinebase_Controller_Record_Abs
         $records = $this->search($filter, $pagination);
 
         foreach ($records as $record) {
-            // TODO add failcount to filter in getScheduledImportFilter as
-            //   no more valid imports are run if we have 50+ failing imports
             if ($record->failcount < self::MAXFAILCOUNT) {
                 return $record;
             } else {
index d5f647e..89db34f 100644 (file)
@@ -45,6 +45,7 @@ class Tinebase_Model_ImportFilter extends Tinebase_Model_Filter_FilterGroup
         'timestamp'      => array('filter' => 'Tinebase_Model_Filter_DateTime'),
         'synctoken'      => array('filter' => 'Tinebase_Model_Filter_Text'),
         'container_id'   => array('filter' => 'Tinebase_Model_Filter_Id'),
-        'application_id' => array('filter' => 'Tinebase_Model_Filter_Id')
+        'application_id' => array('filter' => 'Tinebase_Model_Filter_Id'),
+        'failcount'      => array('filter' => 'Tinebase_Model_Filter_Int')
     );
 }