my $all_records = undef;
my $replace_001 = undef;
my @library = ();
+my ($since, $edited);
+my $dtype = 'create_date';
GetOptions(
'help' => \$help,
'encoding=s' => \$encoding,
'timeout=i' => \$timeout,
'library=s' => \@library,
+ 'since=s' => \$since,
+ 'edited' => \$edited,
);
if ($help) {
Not compatible with --format=BRE
--location or -l MARC Location Code for holdings from
http://www.loc.gov/marc/organizations/orgshome.html
+ --since or -s Export records created from (including) this date;
+ requires the --all flag and 'YYYY-MM-DD' format
+ --edited Export records edited since (including) this date;
+ requires the --all and -s flags and 'YYYY-MM-DD' format
Examples:
$0 --library BR1 --library BR2 --encoding UTF-8 > sys1_bibs.mrc
+To export records created since (including) a certain date:
+ $0 --all --since=2013-05-01 > output_file
+
+To export records edited since (including) a certain date:
+ $0 --all --edited --since=2013-05-01 > output_file
+
HELP
exit;
}
'records with a request for records by library');
}
+if (defined $since) {
+ die('Incompatible arguments: since requires the --all flag') unless $all_records;
+ # there are all encompassing regexes out there but this is adequate?
+ die('Bad date format, should be valid: YYYY-MM-DD') unless $since =~ /^\d{4}-(0[1-9]|1[0-2])-([0-2]\d|3[01])$/;
+ $dtype = 'edit_date' if defined $edited;
+}
+
$type = lc($type);
$format = uc($format);
$encoding = uc($encoding);
{order_by => { 'are' => 'id DESC' }, limit => 1}
])->[0]->id;
}
+
+ # get list of eligible ids if --since
+ my %ids;
+ if (defined $since) {
+ my $recids = $editor->json_query({
+ select => { bre => ['id'] },
+ from => { bre => {} },
+ where => {
+ '+bre' => {
+ deleted => 'f',
+ $dtype => {
+ '>=' => $since,
+ },
+ },
+ },
+ });
+ %ids = map { $_->{id} => 1 } @$recids;
+ }
+
for (my $i = 0; $i++ < $top_record;) {
+ if (defined $since) {
+ next unless $ids{$i};
+ }
export_record($i);
}
} elsif (@library) {