Lines 53-58
my (
Link Here
|
53 |
$ending_callnumber, |
53 |
$ending_callnumber, |
54 |
$start_accession, |
54 |
$start_accession, |
55 |
$end_accession, |
55 |
$end_accession, |
|
|
56 |
$days_old, |
57 |
$months_old, |
56 |
$marc_conditions, |
58 |
$marc_conditions, |
57 |
$help |
59 |
$help |
58 |
); |
60 |
); |
Lines 77-82
GetOptions(
Link Here
|
77 |
'ending_callnumber=s' => \$ending_callnumber, |
79 |
'ending_callnumber=s' => \$ending_callnumber, |
78 |
'start_accession=s' => \$start_accession, |
80 |
'start_accession=s' => \$start_accession, |
79 |
'end_accession=s' => \$end_accession, |
81 |
'end_accession=s' => \$end_accession, |
|
|
82 |
'days_old=s' => \$days_old, |
83 |
'months_old=s' => \$months_old, |
80 |
'marc_conditions=s' => \$marc_conditions, |
84 |
'marc_conditions=s' => \$marc_conditions, |
81 |
'h|help|?' => \$help |
85 |
'h|help|?' => \$help |
82 |
) || pod2usage(1); |
86 |
) || pod2usage(1); |
Lines 109-117
if ( $deleted_barcodes and $record_type ne 'bibs' ) {
Link Here
|
109 |
pod2usage(q|--deleted_barcodes can only be used with biblios|); |
113 |
pod2usage(q|--deleted_barcodes can only be used with biblios|); |
110 |
} |
114 |
} |
111 |
|
115 |
|
|
|
116 |
if ( $days_old and $record_type ne 'bibs' ) { |
117 |
pod2usage(q|days_old can only be used with biblios|); |
118 |
} |
119 |
|
120 |
if ( $months_old and $record_type ne 'bibs' ) { |
121 |
pod2usage(q|months_old can only be used with biblios|); |
122 |
} |
123 |
|
112 |
$start_accession = dt_from_string( $start_accession ) if $start_accession; |
124 |
$start_accession = dt_from_string( $start_accession ) if $start_accession; |
113 |
$end_accession = dt_from_string( $end_accession ) if $end_accession; |
125 |
$end_accession = dt_from_string( $end_accession ) if $end_accession; |
114 |
|
126 |
|
|
|
127 |
# Fetch date in the past |
128 |
my $date; |
129 |
if ( $days_old || $months_old ) { |
130 |
$date = DateTime->now(); |
131 |
if ( $days_old ) { |
132 |
$date->subtract( days => $days_old ); |
133 |
} elsif ( $months_old ) { |
134 |
$date->set_day(1); |
135 |
$date->subtract( months => $months_old ); |
136 |
} |
137 |
} |
138 |
|
115 |
# Parse marc conditions |
139 |
# Parse marc conditions |
116 |
my @marc_conditions; |
140 |
my @marc_conditions; |
117 |
if ($marc_conditions) { |
141 |
if ($marc_conditions) { |
Lines 139-169
my @record_ids;
Link Here
|
139 |
$timestamp = ($timestamp) ? output_pref({ dt => dt_from_string($timestamp), dateformat => 'iso', dateonly => 0, }): ''; |
163 |
$timestamp = ($timestamp) ? output_pref({ dt => dt_from_string($timestamp), dateformat => 'iso', dateonly => 0, }): ''; |
140 |
|
164 |
|
141 |
if ( $record_type eq 'bibs' ) { |
165 |
if ( $record_type eq 'bibs' ) { |
142 |
if ( $timestamp ) { |
166 |
if ( $timestamp || $date ) { |
143 |
if (!$dont_export_items) { |
167 |
if ( $timestamp ) { |
144 |
push @record_ids, $_->{biblionumber} for @{ |
168 |
if (!$dont_export_items) { |
145 |
$dbh->selectall_arrayref(q| ( |
169 |
push @record_ids, $_->{biblionumber} for @{ |
146 |
SELECT biblio_metadata.biblionumber |
170 |
$dbh->selectall_arrayref(q| ( |
147 |
FROM biblio_metadata |
171 |
SELECT biblio_metadata.biblionumber |
148 |
LEFT JOIN items USING(biblionumber) |
172 |
FROM biblio_metadata |
149 |
WHERE biblio_metadata.timestamp >= ? |
173 |
LEFT JOIN items USING(biblionumber) |
150 |
OR items.timestamp >= ? |
174 |
LEFT JOIN biblio USING(biblionumber) |
151 |
) UNION ( |
175 |
WHERE biblio_metadata.timestamp >= ? |
152 |
SELECT biblio_metadata.biblionumber |
176 |
OR items.timestamp >= ? |
153 |
FROM biblio_metadata |
177 |
) UNION ( |
154 |
LEFT JOIN deleteditems USING(biblionumber) |
178 |
SELECT biblio_metadata.biblionumber |
155 |
WHERE biblio_metadata.timestamp >= ? |
179 |
FROM biblio_metadata |
156 |
OR deleteditems.timestamp >= ? |
180 |
LEFT JOIN deleteditems USING(biblionumber) |
157 |
) |, { Slice => {} }, ( $timestamp ) x 4 ); |
181 |
LEFT JOIN biblio USING(biblionumber) |
158 |
}; |
182 |
WHERE biblio_metadata.timestamp >= ? |
159 |
} else { |
183 |
OR deleteditems.timestamp >= ? |
160 |
push @record_ids, $_->{biblionumber} for @{ |
184 |
) |, { Slice => {} }, ( $timestamp ) x 4 ); |
161 |
$dbh->selectall_arrayref(q| ( |
185 |
}; |
162 |
SELECT biblio_metadata.biblionumber |
186 |
} else { |
163 |
FROM biblio_metadata |
187 |
push @record_ids, $_->{biblionumber} for @{ |
164 |
WHERE biblio_metadata.timestamp >= ? |
188 |
$dbh->selectall_arrayref(q| ( |
165 |
) |, { Slice => {} }, $timestamp ); |
189 |
SELECT biblio_metadata.biblionumber |
166 |
}; |
190 |
FROM biblio_metadata |
|
|
191 |
WHERE biblio_metadata.timestamp >= ? |
192 |
) |, { Slice => {} }, $timestamp ); |
193 |
}; |
194 |
} |
195 |
} elsif ( $date ) { |
196 |
if (!$dont_export_items) { |
197 |
push @record_ids, $_->{biblionumber} for @{ |
198 |
$dbh->selectall_arrayref(q| ( |
199 |
SELECT biblio_metadata.biblionumber |
200 |
FROM biblio_metadata |
201 |
LEFT JOIN items USING(biblionumber) |
202 |
LEFT JOIN biblio USING(biblionumber) |
203 |
WHERE biblio.datecreated >= ? |
204 |
) UNION ( |
205 |
SELECT biblio_metadata.biblionumber |
206 |
FROM biblio_metadata |
207 |
LEFT JOIN deleteditems USING(biblionumber) |
208 |
LEFT JOIN biblio USING(biblionumber) |
209 |
WHERE biblio.datecreated >= ? |
210 |
) |, { Slice => {} }, ( $date ) x 2 ); |
211 |
}; |
212 |
} else { |
213 |
push @record_ids, $_->{biblionumber} for @{ |
214 |
$dbh->selectall_arrayref(q| ( |
215 |
SELECT biblio_metadata.biblionumber |
216 |
FROM biblio_metadata |
217 |
LEFT JOIN biblio USING(biblionumber) |
218 |
WHERE biblio.datecreated >= ? |
219 |
) |, { Slice => {} }, $date ); |
220 |
}; |
221 |
} |
167 |
} |
222 |
} |
168 |
} else { |
223 |
} else { |
169 |
my $conditions = { |
224 |
my $conditions = { |
Lines 395-400
Print a brief help message.
Link Here
|
395 |
"exists(<marc_target>)" will include marc records where |
450 |
"exists(<marc_target>)" will include marc records where |
396 |
no <marc_target> exists. |
451 |
no <marc_target> exists. |
397 |
|
452 |
|
|
|
453 |
=item B<--days_old> |
454 |
|
455 |
--days_old=NUMBER OF DAYS Export biblio with a datecreated less than the number of days defined. |
456 |
This can only be used to export biblio records. |
457 |
|
458 |
=item B<--months_old> |
459 |
|
460 |
--months_old=NUMBER OF MONTHS Export biblio with a datecreated less than the number of months defined. |
461 |
This can only be used to export biblio records. |
462 |
|
398 |
=back |
463 |
=back |
399 |
|
464 |
|
400 |
=head1 AUTHOR |
465 |
=head1 AUTHOR |
401 |
- |
|
|