[open-ils-commits] [GIT] Evergreen ILS branch master updated. ebecc44027af204c8f5ec8ca790a4753dbcf2fc3
Evergreen Git
git at git.evergreen-ils.org
Tue Dec 18 01:01:19 EST 2012
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via ebecc44027af204c8f5ec8ca790a4753dbcf2fc3 (commit)
via 9db6daf7af1b66712c3c6bc186de4995ff45e7f6 (commit)
via bb93a7ad1cb98559c1562f20485a576ea5832383 (commit)
via 9cf053f05c4996c75760f39fe812b5b851aca4a3 (commit)
via 3b5a7dcf0f763f4665db74e7185813d221554deb (commit)
from 0ad4dd6d7f856dbc5ccf6bce5f3ab74d13898396 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ebecc44027af204c8f5ec8ca790a4753dbcf2fc3
Author: Ben Shum <bshum at biblio.org>
Date: Tue Dec 18 01:00:07 2012 -0500
Stamping upgrade script for frozen holds clear expire time
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index d069cc0..5fd64c1 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -87,7 +87,7 @@ CREATE TRIGGER no_overlapping_deps
BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0746', :eg_version); -- mrpeters-isl/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0747', :eg_version); -- dyrcona/bshum
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql b/Open-ILS/src/sql/Pg/upgrade/0747.data.frozen_holds_clear_expire_time.sql
similarity index 77%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql
rename to Open-ILS/src/sql/Pg/upgrade/0747.data.frozen_holds_clear_expire_time.sql
index 2bd15b8..3dea928 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0747.data.frozen_holds_clear_expire_time.sql
@@ -2,7 +2,7 @@
-- Set the expire_time to NULL on all frozen/suspended holds.
BEGIN;
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0747', :eg_version);
UPDATE action.hold_request
SET expire_time = NULL
commit 9db6daf7af1b66712c3c6bc186de4995ff45e7f6
Author: Jason Stephenson <jstephenson at mvlc.org>
Date: Wed Nov 14 13:41:37 2012 -0500
LP1076399: Prevent reactivated holds from expiring immediately.
Clear the expire_time on deactivated holds.
Recalculate the expire_time when a hold is reactivated.
Upgrade script to set expire_time to NULL on frozen action.hold_requests.
Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index 3e32d62..0b188bf 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -1009,6 +1009,9 @@ sub update_hold_impl {
$logger->info("clearing current_copy and check_time for frozen hold ".$hold->id);
$hold->clear_current_copy;
$hold->clear_prev_check_time;
+ # Clear expire_time to prevent frozen holds from expiring.
+ $logger->info("clearing expire_time for frozen hold ".$hold->id);
+ $hold->clear_expire_time;
}
# If the hold_expire_time is in the past && is not equal to the
@@ -1018,6 +1021,12 @@ sub update_hold_impl {
$hold->expire_time(calculate_expire_time($hold->request_lib));
}
+ # If the hold is reactivated, reset the expire_time.
+ if(!$U->is_true($hold->frozen) && $U->is_true($orig_hold->frozen)) {
+ $logger->info("Reset expire_time on activated hold ".$hold->id);
+ $hold->expire_time(calculate_expire_time($hold->request_lib));
+ }
+
$e->update_action_hold_request($hold) or return $e->die_event;
$e->commit;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql
new file mode 100644
index 0000000..2bd15b8
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql
@@ -0,0 +1,11 @@
+-- LP1076399: Prevent reactivated holds from canceling immediately.
+-- Set the expire_time to NULL on all frozen/suspended holds.
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+UPDATE action.hold_request
+SET expire_time = NULL
+WHERE frozen = 't';
+
+COMMIT;
commit bb93a7ad1cb98559c1562f20485a576ea5832383
Author: Jason Stephenson <jstephenson at mvlc.org>
Date: Wed Nov 14 11:49:49 2012 -0500
Resolve LP893448: Prevent hold expiration in past.
If a hold is placed with an expiration date in the past, the
expire_time of the hold will be reset using the hold expiration
interval settings.
Likewise, if a hold is changed to have an expiration date in the
past, the hold expiration date will be recalculated using the
hold expiration interval settings.
Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index 617f4de..3e32d62 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -315,6 +315,9 @@ sub create_hold {
}
}
+ # Check for hold expiration in the past, and set it to empty string.
+ $hold->expire_time(undef) if ($hold->expire_time && $U->datecmp($hold->expire_time) == -1);
+
# set the configured expire time
unless($hold->expire_time) {
$hold->expire_time(calculate_expire_time($recipient->home_ou));
@@ -1008,6 +1011,13 @@ sub update_hold_impl {
$hold->clear_prev_check_time;
}
+ # If the hold_expire_time is in the past && is not equal to the
+ # original expire_time, then reset the expire time to be in the
+ # future.
+ if ($hold->expire_time && $U->datecmp($hold->expire_time) == -1 && $U->datecmp($hold->expire_time, $orig_hold->expire_time) != 0) {
+ $hold->expire_time(calculate_expire_time($hold->request_lib));
+ }
+
$e->update_action_hold_request($hold) or return $e->die_event;
$e->commit;
commit 9cf053f05c4996c75760f39fe812b5b851aca4a3
Author: Jason Stephenson <jstephenson at mvlc.org>
Date: Wed Nov 14 11:27:53 2012 -0500
Add calculate_expire_time helper function to Holds.pm.
This new function calculates an expire_time for a hold based on the hold
expiration interval setting for a passed in org_unit. If the setting is found
the interval is added to "now" and returned as an ISO8601 string. undef is
returned if the setting is not found for the org_unit or its ancestors.
Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index 1a647c9..617f4de 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -317,11 +317,7 @@ sub create_hold {
# set the configured expire time
unless($hold->expire_time) {
- my $interval = $U->ou_ancestor_setting_value($recipient->home_ou, OILS_SETTING_HOLD_EXPIRE);
- if($interval) {
- my $date = DateTime->now->add(seconds => OpenSRF::Utils::interval_to_seconds($interval));
- $hold->expire_time($U->epoch2ISO8601($date->epoch));
- }
+ $hold->expire_time(calculate_expire_time($recipient->home_ou));
}
$hold->requestor($e->requestor->id);
@@ -683,11 +679,7 @@ sub uncancel_hold {
$hold->request_lib, 'circ.holds.uncancel.reset_request_time', $e)) {
$hold->request_time('now');
- my $interval = $U->ou_ancestor_setting_value($hold->request_lib, OILS_SETTING_HOLD_EXPIRE);
- if($interval) {
- my $date = DateTime->now->add(seconds => OpenSRF::Utils::interval_to_seconds($interval));
- $hold->expire_time($U->epoch2ISO8601($date->epoch));
- }
+ $hold->expire_time(calculate_expire_time($hold->request_lib));
}
$hold->clear_cancel_time;
@@ -3981,9 +3973,19 @@ sub rec_hold_count {
return new_editor()->json_query($query)->[0]->{count};
}
-
-
-
-
+# A helper function to calculate a hold's expiration time at a given
+# org_unit. Takes the org_unit as an argument and returns either the
+# hold expire time as an ISO8601 string or undef if there is no hold
+# expiration interval set for the subject ou.
+sub calculate_expire_time
+{
+ my $ou = shift;
+ my $interval = $U->ou_ancestor_setting_value($ou, OILS_SETTING_HOLD_EXPIRE);
+ if($interval) {
+ my $date = DateTime->now->add(seconds => OpenSRF::Utils::interval_to_seconds($interval));
+ return $U->epoch2ISO8601($date->epoch);
+ }
+ return undef;
+}
1;
commit 3b5a7dcf0f763f4665db74e7185813d221554deb
Author: Jason Stephenson <jstephenson at mvlc.org>
Date: Wed Nov 14 10:40:35 2012 -0500
Add datecmp to OpenILS::Application::AppUtils.
datecmp is a handy subroutine for comparing two DateTime objects or string
represenations. It returns -1, 0, and 1, much like the perl cmp operator.
If only 1 date is specified, then it will be compared to DateTime->now.
Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
index 2529d6b..e4d1e7d 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
@@ -15,6 +15,8 @@ use Unicode::Normalize;
use OpenSRF::Utils::SettingsClient;
use UUID::Tiny;
use Encode;
+use DateTime;
+use DateTime::Format::ISO8601;
# ---------------------------------------------------------------------------
# Pile of utilty methods used accross applications.
@@ -2028,5 +2030,44 @@ sub basic_opac_copy_query {
};
}
+# Compare two dates, date1 and date2. If date2 is not defined, then
+# DateTime->now will be used. Assumes dates are in ISO8601 format as
+# supported by DateTime::Format::ISO8601. (A future enhancement might
+# be to support other formats.)
+#
+# Returns -1 if $date1 < $date2
+# Returns 0 if $date1 == $date2
+# Returns 1 if $date1 > $date2
+sub datecmp {
+ my $self = shift;
+ my $date1 = shift;
+ my $date2 = shift;
+
+ # Check for timezone offsets and limit them to 2 digits:
+ if ($date1 && $date1 =~ /(?:-|\+)\d\d\d\d$/) {
+ $date1 = substr($date1, 0, length($date1) - 2);
+ }
+ if ($date2 && $date2 =~ /(?:-|\+)\d\d\d\d$/) {
+ $date2 = substr($date2, 0, length($date2) - 2);
+ }
+
+ # check date1:
+ unless (UNIVERSAL::isa($date1, "DateTime")) {
+ $date1 = DateTime::Format::ISO8601->parse_datetime($date1);
+ }
+
+ # Check for date2:
+ unless ($date2) {
+ $date2 = DateTime->now;
+ } else {
+ unless (UNIVERSAL::isa($date2, "DateTime")) {
+ $date2 = DateTime::Format::ISO8601->parse_datetime($date2);
+ }
+ }
+
+ return DateTime->compare($date1, $date2);
+}
+
+
1;
-----------------------------------------------------------------------
Summary of changes:
.../perlmods/lib/OpenILS/Application/AppUtils.pm | 41 ++++++++++++++++
.../perlmods/lib/OpenILS/Application/Circ/Holds.pm | 49 ++++++++++++++------
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
.../0747.data.frozen_holds_clear_expire_time.sql | 11 ++++
4 files changed, 88 insertions(+), 15 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0747.data.frozen_holds_clear_expire_time.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list