-# list metadata records from the archive
-sub Archive_ListRecords
-{
- my ($self, $set, $from, $until, $metadataPrefix, $resumptionToken) = @_;
-
- my @allrows = ();
- my $marc;
- my $offset;
- my $tokenInfo;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("SELECT biblionumber,timestamp FROM biblio WHERE DATE(timestamp) >= ? and DATE(timestamp) <= ? LIMIT ? OFFSET ?");
- my $count;
-
- ($metadataPrefix, $offset, $from, $until ) = &parseResumptionToken($from, $until, $metadataPrefix, $resumptionToken);
-
-warn( "Archive_ListRecords : $set, $from, $until, $metadataPrefix, $resumptionToken\n");
- $sth->execute( $from,$until,$self->{'MaxCount'}?$self->{'MaxCount'}:100000, $offset );
-
- while( my $r = $sth->fetchrow_hashref() ) {
- my $marc = new MARC::Record::KOHADC( ::GetMarcBiblio( $r->{'biblionumber'} ) );
- $marc->{'biblio.timestamp'} = $r->{'timestamp'};
- push( @allrows, $marc );
- }
-
- $sth = $dbh->prepare("SELECT count(*) FROM biblioitems WHERE DATE(timestamp) >= ? and DATE(timestamp) <= ?");
- $sth->execute($from, $until);
- ( $count ) = $sth->fetchrow_array();
-
- unless( @allrows ) {
- $self->AddError ('noRecordsMatch', 'The combination of the values of arguments results in an empty set');
- }
-
- if( $offset + $self->{'MaxCount'} < $count ) { # Not at the end
- $offset = $offset + $self->{'MaxCount'};
- $resumptionToken = &buildResumptionToken($metadataPrefix,$offset,$from,$until);
- $tokenInfo = { 'completeListSize' => $count, 'cursor' => $offset };
- }
- else {
- $resumptionToken = '';
- $tokenInfo = {};
- }
- ( \@allrows, $resumptionToken, $metadataPrefix, $tokenInfo );
-}