Bug 17778 - Make "Earliest Registered Date" in OAI dynamic

This was hardcoded to 0001-01-01.

To test:
- Make sure you have a couple of records, with different timestamps
- Enable OAI-PMH
- Check http://localhost:2201/cgi-bin/koha/oai.pl?verb=Identify
  and verify that "Earliest Registered Date" is 0001-01-01
- Apply the patch
- Re-check the "Earliest Registered Date" and verify that it is now
  the lowest timestamp in your biblio table
- Manipulate the timestamps and verify that "Earliest Registered Date"
  changes accordingly
- Sign off!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Magnus Enger 2017-01-06 15:27:04 +01:00 committed by Kyle M Hall
parent ae8223e333
commit ff711c48cf
1 changed files with 15 additions and 1 deletions

View File

@ -34,7 +34,7 @@ sub new {
adminEmail => C4::Context->preference("KohaAdminEmailAddress"),
MaxCount => C4::Context->preference("OAI-PMH:MaxCount"),
granularity => 'YYYY-MM-DD',
earliestDatestamp => '0001-01-01',
earliestDatestamp => _get_earliest_datestamp() || '0001-01-01',
deletedRecord => C4::Context->preference("OAI-PMH:DeletedRecord") || 'no',
);
@ -49,4 +49,18 @@ sub new {
return $self;
}
# Find the earliest timestamp in the biblio table. If this table is empty, undef
# will be returned and we will report the fallback 0001-01-01.
sub _get_earliest_datestamp {
my $dbh = C4::Context->dbh;
my $order_sth = $dbh->prepare( "SELECT DATE(MIN(timestamp)) AS earliest FROM biblio" );
$order_sth->execute();
my $res = $order_sth->fetchrow_hashref();
return $res->{'earliest'};
}
1;