From 63caec45549af7c5a3fc072541a4ce1b96556983 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 4 Jun 2014 17:03:51 +0200 Subject: [PATCH] [PASSED QA] Bug 12368: Rebuild Zebra improvement: allow to specify a DB table Currently the --where parameter only allow to specify a condition on fields in the biblioitems table. For some needs it would be great to specify a condition on the field in the items table. The use case is the following: you want to reindex biblios with items modified since a specific timestamp. Test plan: 1/ Pick an item randomly in your catalogue 2/ Edit it and save 3/ Note that the items.timestamp has been set to today but not the biblioitems.timestamp 4/ launch rebuild_zebra without the new parameter perl misc/migration_tools/rebuild_zebra.pl -b -v --where "timestamp >= XXX" where XXX is the today date (e.g. "2014-06-05 00:00:00"). Note that the biblio has not been indexed. 5/ launch rebuild_zebra using the new parameter: perl misc/migration_tools/rebuild_zebra.pl -b -v -t items --where "timestamp >= XXX" Note the biblio has been indexed. Signed-off-by: Chris Cormack Signed-off-by: Kyle M Hall --- misc/migration_tools/rebuild_zebra.pl | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index aa31cb2..67b73c7 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -48,6 +48,7 @@ my $run_as_root; my $run_user = (getpwuid($<))[0]; my $wait_for_lock = 0; my $use_flock; +my $table = 'biblioitems'; my $verbose_logging = 0; my $zebraidx_log_opt = " -v none,fatal,warn "; @@ -75,6 +76,7 @@ my $result = GetOptions( 'v+' => \$verbose_logging, 'run-as-root' => \$run_as_root, 'wait-for-lock' => \$wait_for_lock, + 't|table:s' => \$table, ); if (not $result or $want_help) { @@ -442,7 +444,10 @@ sub select_all_authorities { } sub select_all_biblios { - my $strsth = qq{ SELECT biblionumber FROM biblioitems }; + $table = 'biblioitems' + if $table ne 'items' + and $table ne 'biblio'; + my $strsth = qq{ SELECT biblionumber FROM $table }; $strsth.=qq{ WHERE $where } if ($where); $strsth.=qq{ LIMIT $length } if ($length && !$offset); $strsth.=qq{ LIMIT $offset,$length } if ($offset); @@ -918,6 +923,9 @@ Parameters: to wait for the lock to free and then continue processing the rebuild request, + --table specify a table (can be items, biblioitems or biblio) to retrieve biblionumber to index. + biblioitems is the default value. + --help or -h show this message. _USAGE_ } -- 1.7.2.5