stanley-king 2 лет назад
Родитель
Сommit
deb026d855
2 измененных файлов с 19 добавлено и 8 удалено
  1. 10 6
      helper/refill/ops/pdlog_clear_refill.php
  2. 9 2
      test/TestRefillClear.php

+ 10 - 6
helper/refill/ops/pdlog_clear_refill.php

@@ -10,7 +10,7 @@ class pdlog_clear_all
     const pdlog_table_name = 'pd_log';
     const step_length = 1000;
 
-    public function clear()
+    public function clear($latest)
     {
         $lgid_getter = function ()
         {
@@ -24,6 +24,10 @@ class pdlog_clear_all
         };
 
         [$succ,$minid,$maxid] = $lgid_getter();
+        if($latest > $minid) {
+            $minid = $latest;
+        }
+
         if($succ) {
             $this->delete_log($minid,$maxid);
         }
@@ -122,11 +126,11 @@ class pdlog_clear_all
                     $count += count($logids);
                     Log::record("del pd_log lines={$count}",Log::DEBUG);
 
-                    $index += 1;
-                    if($index % 1000 === 0) {
-                        Log::record("del pd_log index={$index}",Log::DEBUG);
-                        sleep(1);
-                    }
+//                    $index += 1;
+//                    if($index % 1000 === 0) {
+//                        Log::record("del pd_log index={$index}",Log::DEBUG);
+//                        sleep(1);
+//                    }
                 }
             }
         };

+ 9 - 2
test/TestRefillClear.php

@@ -38,10 +38,17 @@ class TestRefillClear extends TestCase
     }
 
     //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillClear::testPdlogClearAll)( .*)?$/" --test-suffix TestRefillClear.php /var/www/html/test
-    public function testPdlogClearAll()
+    public function testPdlogClearYZAll()
     {
         $clear = new refill\pdlog_clear_all();
-        $clear->clear();
+        $clear->clear(5830744042);
+    }
+
+    //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillClear::testPdlogClearAll)( .*)?$/" --test-suffix TestRefillClear.php /var/www/html/test
+    public function testPdlogClearYLAll()
+    {
+        $clear = new refill\pdlog_clear_all();
+        $clear->clear(7371133601);
     }
 
     //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillClear::testClearFirstDay)( .*)?$/" --test-suffix TestRefillClear.php /var/www/html/test