Bugzilla – Attachment 151879 Details for
Bug 33871
Add where parameter to sitemap.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33871: Use Koha object in Sitemapper, add optional filter
Bug-33871-Use-Koha-object-in-Sitemapper-add-option.patch (text/plain), 3.72 KB, created by
Marcel de Rooy
on 2023-05-31 13:20:46 UTC
(
hide
)
Description:
Bug 33871: Use Koha object in Sitemapper, add optional filter
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-05-31 13:20:46 UTC
Size:
3.72 KB
patch
obsolete
>From 2483eded4e40ab6eb01b76173cb8df05076c8c5d Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 31 May 2023 11:44:26 +0000 >Subject: [PATCH] Bug 33871: Use Koha object in Sitemapper, add optional filter >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run misc/cronjobs/sitemap.pl -where "biblionumber>X" (replace X >by some clever value) >Verify results by browsing sitemap files. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Sitemapper.pm | 23 +++++++++++------------ > misc/cronjobs/sitemap.pl | 11 +++++++++-- > 2 files changed, 20 insertions(+), 14 deletions(-) > >diff --git a/Koha/Sitemapper.pm b/Koha/Sitemapper.pm >index eab42f35ba..6c2520781d 100644 >--- a/Koha/Sitemapper.pm >+++ b/Koha/Sitemapper.pm >@@ -18,10 +18,11 @@ package Koha::Sitemapper; > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use Moo; > use Modern::Perl; >+use Moo; >+ >+use Koha::Biblios; > use Koha::Sitemapper::Writer; >-use C4::Context; > > > has url => ( is => 'rw', ); >@@ -50,18 +51,16 @@ has count => ( is => 'rw', default => sub { 0 } ); > > > sub run { >- my $self = shift; >+ my ( $self, $where ) = @_; >+ my $filter = $where ? \$where : {}; > > say "Creation of Sitemap files in '" . $self->dir . "' directory" > if $self->verbose; > > $self->writer( Koha::Sitemapper::Writer->new( sitemapper => $self ) ); >- my $sth = C4::Context->dbh->prepare( >- "SELECT biblionumber, timestamp FROM biblio" ); >- $sth->execute(); >- $self->sth($sth); >+ my $rs = Koha::Biblios->search( $filter, { columns => [ qw/biblionumber timestamp/ ] }); > >- while ( $self->process() ) { >+ while ( $self->process($rs) ) { > say "..... ", $self->count > if $self->verbose && $self->count % 10000 == 0; > } >@@ -69,10 +68,10 @@ sub run { > > > sub process { >- my $self = shift; >+ my ( $self, $rs ) = @_; > >- my ($biblionumber, $timestamp) = $self->sth->fetchrow; >- unless ($biblionumber) { >+ my $biblio = $rs->next; >+ unless( $biblio ) { > $self->writer->end(); > say "Number of biblio records processed: ", $self->count, "\n" . > "Number of Sitemap files: ", $self->writer->count >@@ -80,7 +79,7 @@ sub process { > return; > } > >- $self->writer->write($biblionumber, $timestamp); >+ $self->writer->write( $biblio->biblionumber, $biblio->timestamp ); > $self->count( $self->count + 1 ); > return $self->count; > } >diff --git a/misc/cronjobs/sitemap.pl b/misc/cronjobs/sitemap.pl >index 93abb02ed0..4b4576a567 100755 >--- a/misc/cronjobs/sitemap.pl >+++ b/misc/cronjobs/sitemap.pl >@@ -29,12 +29,14 @@ use Koha::Sitemapper; > > > my ($verbose, $help, $url, $dir, $short) = (0, 0, '', '.', 1); >+my $where; > GetOptions( > 'verbose' => \$verbose, > 'help' => \$help, > 'url=s' => \$url, > 'dir=s' => \$dir, > 'short!' => \$short, >+ 'where=s' => \$where, > ); > > sub usage { >@@ -59,14 +61,14 @@ my $sitemapper = Koha::Sitemapper->new( > dir => $dir, > short => $short, > ); >-$sitemapper->run(); >+$sitemapper->run($where); > > > =head1 USAGE > > =over > >-=item sitemap.pl [--verbose|--help|--short|--noshort|--url|--dir] >+=item sitemap.pl [--verbose|--help|--short|--noshort|--url|--dir|--where ] > > =back > >@@ -75,6 +77,7 @@ $sitemapper->run(); > sitemap.pl --verbose > sitemap.pl --noshort --dir /home/koha/mylibrary/www > sitemap.pl --url opac.myDNSname.org >+ sitemap.pl --where 'biblionumber<100' > > =head1 DESCRIPTION > >@@ -123,6 +126,10 @@ records processed. > > Print this help page. > >+=item B<--where> >+ >+Add a filter to limit the selection of biblio records. May be useful when testing the feature. >+ > =back > > =cut >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33871
:
151879
|
151880
|
153458
|
153534
|
153535
|
155107
|
155108