Lines 18-27
package Koha::Sitemapper;
Link Here
|
18 |
# You should have received a copy of the GNU General Public License |
18 |
# You should have received a copy of the GNU General Public License |
19 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
20 |
|
20 |
|
21 |
use Moo; |
|
|
22 |
use Modern::Perl; |
21 |
use Modern::Perl; |
|
|
22 |
use Moo; |
23 |
|
24 |
use Koha::Biblios; |
23 |
use Koha::Sitemapper::Writer; |
25 |
use Koha::Sitemapper::Writer; |
24 |
use C4::Context; |
|
|
25 |
|
26 |
|
26 |
|
27 |
|
27 |
has url => ( is => 'rw', ); |
28 |
has url => ( is => 'rw', ); |
Lines 50-67
has count => ( is => 'rw', default => sub { 0 } );
Link Here
|
50 |
|
51 |
|
51 |
|
52 |
|
52 |
sub run { |
53 |
sub run { |
53 |
my $self = shift; |
54 |
my ( $self, $where ) = @_; |
|
|
55 |
my $filter = $where ? \$where : {}; |
54 |
|
56 |
|
55 |
say "Creation of Sitemap files in '" . $self->dir . "' directory" |
57 |
say "Creation of Sitemap files in '" . $self->dir . "' directory" |
56 |
if $self->verbose; |
58 |
if $self->verbose; |
57 |
|
59 |
|
58 |
$self->writer( Koha::Sitemapper::Writer->new( sitemapper => $self ) ); |
60 |
$self->writer( Koha::Sitemapper::Writer->new( sitemapper => $self ) ); |
59 |
my $sth = C4::Context->dbh->prepare( |
61 |
my $rs = Koha::Biblios->search( $filter, { columns => [ qw/biblionumber timestamp/ ] }); |
60 |
"SELECT biblionumber, timestamp FROM biblio" ); |
|
|
61 |
$sth->execute(); |
62 |
$self->sth($sth); |
63 |
|
62 |
|
64 |
while ( $self->process() ) { |
63 |
while ( $self->process($rs) ) { |
65 |
say "..... ", $self->count |
64 |
say "..... ", $self->count |
66 |
if $self->verbose && $self->count % 10000 == 0; |
65 |
if $self->verbose && $self->count % 10000 == 0; |
67 |
} |
66 |
} |
Lines 69-78
sub run {
Link Here
|
69 |
|
68 |
|
70 |
|
69 |
|
71 |
sub process { |
70 |
sub process { |
72 |
my $self = shift; |
71 |
my ( $self, $rs ) = @_; |
73 |
|
72 |
|
74 |
my ($biblionumber, $timestamp) = $self->sth->fetchrow; |
73 |
my $biblio = $rs->next; |
75 |
unless ($biblionumber) { |
74 |
unless( $biblio ) { |
76 |
$self->writer->end(); |
75 |
$self->writer->end(); |
77 |
say "Number of biblio records processed: ", $self->count, "\n" . |
76 |
say "Number of biblio records processed: ", $self->count, "\n" . |
78 |
"Number of Sitemap files: ", $self->writer->count |
77 |
"Number of Sitemap files: ", $self->writer->count |
Lines 80-86
sub process {
Link Here
|
80 |
return; |
79 |
return; |
81 |
} |
80 |
} |
82 |
|
81 |
|
83 |
$self->writer->write($biblionumber, $timestamp); |
82 |
$self->writer->write( $biblio->biblionumber, $biblio->timestamp ); |
84 |
$self->count( $self->count + 1 ); |
83 |
$self->count( $self->count + 1 ); |
85 |
return $self->count; |
84 |
return $self->count; |
86 |
} |
85 |
} |