-- These are copy level holds
-- CREATE TABLE legacy_copy_hold_insert AS
-INSERT INTO action.hold_request
- (id, target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr)
+create table copy_hold_fix as
SELECT lh.hold_key AS id,
cp.id AS target,
cp.id AS current_copy,
ELSE 2
END AS selection_depth,
lh.hold_date AS request_time,
- CASE WHEN lh.available IN ('Y','I') THEN now()
+ CASE WHEN lh.available IN ('Y','I') THEN '2006-09-01'::timestamptz
ELSE NULL
END AS capture_time,
rou.id AS request_lib,
WHERE lh.hold_level = 'C'
AND lh.hold_date > '2006-01-01';
+
-- And these are CN level holds
-- CREATE TABLE legacy_cn_hold_insert AS
-INSERT INTO action.hold_request
- (id, target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr)
+create table cn_hold_fix as
SELECT lh.hold_key AS id,
cp.call_number AS target,
cp.id AS current_copy,
ELSE 2
END AS selection_depth,
lh.hold_date AS request_time,
- CASE WHEN lh.available IN ('Y','I') THEN now()
+ CASE WHEN lh.available IN ('Y','I') THEN '2006-09-01'::timestamptz
ELSE NULL
END AS capture_time,
rou.id AS request_lib,
-- And these are Title level holds
-- CREATE TABLE legacy_title_hold_insert AS
-INSERT INTO action.hold_request
- (id, target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr)
+create table title_hold_fix as
SELECT lh.hold_key AS id,
lh.cat_key AS target,
cp.id AS current_copy,
ELSE 2
END AS selection_depth,
lh.hold_date AS request_time,
- CASE WHEN lh.available IN ('Y','I') THEN now()
+ CASE WHEN lh.available IN ('Y','I') THEN '2006-09-01'::timestamptz
ELSE NULL
END AS capture_time,
rou.id AS request_lib,
ORDER BY close_start ASC, close_end DESC
SQL
+ $date = clense_ISO8601($date);
+
my $sth = actor::org_unit::closed_date->db_Main->prepare( $sql );
$sth->execute($date, $ou);
-
- $date = clense_ISO8601($date);
my ($begin, $end);
while (my $closure = $sth->fetchrow_hashref) {
- $begin ||= $closure->{close_start};
- $end = $closure->{close_end};
-
- my $before = $_dt_parser->parse_datetime( clense_ISO8601($begin) );
- $before->subtract( seconds => 1 );
- my $after = $_dt_parser->parse_datetime( clense_ISO8601($end) );
- $after->add( seconds => 1 );
+ $begin ||= clense_ISO8601($closure->{close_start});
+ $end = clense_ISO8601($closure->{close_end});
if ( $direction <= 0 ) {
+ $before = $_dt_parser->parse_datetime( $begin );
+ $before->subtract( minutes => 1 );
+
while ( my $_b = org_closed_overlap($self, $client, $ou, $before->iso8601, -1, 1 ) ) {
$before = $_dt_parser->parse_datetime( clense_ISO8601($_b->{start}) );
}
+ $begin = clense_ISO8601($before->iso8601);
}
if ( $direction >= 0 ) {
+ $after = $_dt_parser->parse_datetime( $end );
+ $after->add( minutes => 1 );
+
while ( my $_a = org_closed_overlap($self, $client, $ou, $after->iso8601, 1, 1 ) ) {
$after = $_dt_parser->parse_datetime( clense_ISO8601($_a->{end}) );
}
+ $end = clense_ISO8601($after->iso8601);
}
- $begin = clense_ISO8601($before->iso8601);
- $end = clense_ISO8601($after->iso8601);
}
$begin ||= $date;