Improve populateIpChanges.php reporting
authorMax Semenik <maxsem.wiki@gmail.com>
Wed, 20 Sep 2017 03:38:20 +0000 (20:38 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Wed, 20 Sep 2017 03:38:20 +0000 (20:38 -0700)
Instead of just the rows we attempted to insert, also count
actually inserted ones.

Change-Id: Ie747cb41873640776281794a90dbe3b6b8e3fa84

maintenance/populateIpChanges.php

index f7bcc12..2b2a2b4 100644 (file)
@@ -72,7 +72,8 @@ TEXT
                        ? $maxRevId
                        : $dbw->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ );
                $blockStart = $start;
-               $revCount = 0;
+               $attempted = 0;
+               $inserted = 0;
 
                $this->output( "Copying IP revisions to ip_changes, from rev_id $start to rev_id $end\n" );
 
@@ -105,7 +106,7 @@ TEXT
                                                'ipc_hex' => IP::toHex( $row->rev_user_text ),
                                        ];
 
-                                       $revCount++;
+                                       $attempted++;
                                }
                        }
 
@@ -116,13 +117,15 @@ TEXT
                                'IGNORE'
                        );
 
+                       $inserted += $dbw->affectedRows();
+
                        $lbFactory->waitForReplication();
                        usleep( $throttle * 1000 );
 
                        $blockStart = $blockEnd + 1;
                }
 
-               $this->output( "$revCount IP revisions copied.\n" );
+               $this->output( "Attempted to insert $attempted IP revisions, $inserted actually done.\n" );
 
                return true;
        }