]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1378999 - Add update/new stats to bulk_indexer verbose mode
authorDylan William Hardison <dylan@hardison.net>
Tue, 11 Jul 2017 22:21:47 +0000 (18:21 -0400)
committerGitHub <noreply@github.com>
Tue, 11 Jul 2017 22:21:47 +0000 (18:21 -0400)
Bugzilla/Elastic/Indexer.pm
scripts/bulk_index.pl

index b691e06877567eb0cb9efbb82e3d8686be34f1cc..35c9bb119052f704703b4396e010b85110506004 100644 (file)
@@ -181,6 +181,11 @@ sub bulk_load {
 
     $self->_bulk_load_ids($bulk, $class, $new_ids) if @$new_ids;
     $self->_bulk_load_ids($bulk, $class, $updated_ids) if @$updated_ids;
+
+    return {
+        new     => scalar @$new_ids,
+        updated => scalar @$updated_ids,
+    };
 }
 
 sub _select_all_ids {
index 1746bc868e7ad304fe86edc26d9fa0b5f2884368..8d04b7e8dd1d1620b20aa12e3c504d01a4217e8d 100755 (executable)
@@ -49,6 +49,7 @@ my $indexer = Bugzilla::Elastic::Indexer->new(
 
 $indexer->create_index;
 
+my $run_time = time;
 my $loop = IO::Async::Loop->new;
 my $timer = IO::Async::Timer::Periodic->new(
     first_interval => 0,
@@ -56,25 +57,32 @@ my $timer = IO::Async::Timer::Periodic->new(
     reschedule     => 'skip',
 
     on_tick => sub {
+        printf "Running after %d seconds\n", time - $run_time;
         my $start_users = time;
         say "indexing users" if $verbose;
-        $indexer->bulk_load('Bugzilla::User');
-        print "    ", time - $start_users, " seconds\n" if $verbose > 1;
+        my $users = $indexer->bulk_load('Bugzilla::User');
+        bulk_load_stats($start_users, $users) if $verbose > 1;
 
-        say "indexing bugs" if $verbose;
         my $start_bugs = time;
-        $indexer->bulk_load('Bugzilla::Bug');
-        print "    ", time - $start_bugs, " seconds\n" if $verbose > 1;
+        say "indexing bugs" if $verbose;
+        my $bugs = $indexer->bulk_load('Bugzilla::Bug');
+        bulk_load_stats($start_bugs, $bugs) if $verbose > 1;
 
-        say "indexing comments" if $verbose;
         my $start_comments = time;
-        $indexer->bulk_load('Bugzilla::Comment');
-        print "    ", time - $start_comments, " seconds\n" if $verbose > 1;
+        say "indexing comments" if $verbose;
+        my $comments = $indexer->bulk_load('Bugzilla::Comment');
+        bulk_load_stats($start_comments, $comments) if $verbose > 1;
 
         $loop->stop if $once;
+        $run_time = time;
     },
 );
 
 $timer->start();
 $loop->add($timer);
 $loop->run;
+
+sub bulk_load_stats {
+    my ($start_time, $info) = @_;
+    printf "    %d seconds (%d new, %d update)\n", time - $start_time, $info->{new}, $info->{updated};
+}