[open-ils-commits] [GIT] Evergreen ILS branch master updated. a9298b25b5948b218ed250b36e6f3962abfc651e

Evergreen Git git at git.evergreen-ils.org
Thu Oct 1 14:51:48 EDT 2015


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  a9298b25b5948b218ed250b36e6f3962abfc651e (commit)
       via  2c42d4cb515d7b35b95bd6b5b6b3b2ac3aec9fe3 (commit)
       via  e174b43ef179828e32f60e71b4c56b691e3e85e0 (commit)
       via  71592293e1be843e4f478f98c3899e068f699e6b (commit)
      from  8d3544ef37b42aaf4c71d38f0c8cbf6d4d1ca53e (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 a9298b25b5948b218ed250b36e6f3962abfc651e
Author: Mike Rylander <mrylander at gmail.com>
Date:   Thu Oct 1 14:50:44 2015 -0400

    Stamping upgrade script and test file
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 14fc532..c9a21dd 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,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 ('0944', :eg_version); -- dwells/kmlussier/dyrcona
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0945', :eg_version); -- berick/miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/t/dob-as-date.pg b/Open-ILS/src/sql/Pg/t/lp838525-dob-as-date.pg
similarity index 100%
rename from Open-ILS/src/sql/Pg/t/dob-as-date.pg
rename to Open-ILS/src/sql/Pg/t/lp838525-dob-as-date.pg
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dob-as-date.sql b/Open-ILS/src/sql/Pg/upgrade/0945.schema.dob-as-date.sql
similarity index 99%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dob-as-date.sql
rename to Open-ILS/src/sql/Pg/upgrade/0945.schema.dob-as-date.sql
index 8953156..12a5fbd 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dob-as-date.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0945.schema.dob-as-date.sql
@@ -1,5 +1,7 @@
 BEGIN;
 
+SELECT evergreen.upgrade_deps_block_check('0945', :eg_version);
+
 DROP VIEW action.all_circulation;
 DROP VIEW reporter.demographic;
 DROP VIEW auditor.actor_usr_lifecycle;

commit 2c42d4cb515d7b35b95bd6b5b6b3b2ac3aec9fe3
Author: Bill Erickson <berickxx at gmail.com>
Date:   Tue Sep 29 12:10:53 2015 -0400

    LP#838525 libdbi DATE types translated via gmtime
    
    libdbi assumes a date (w/ no time or timezone) is GMT.  Parse the date
    via gmtime() instead of localtime() to ensure the date returned to the
    caller matches the date in the DB.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/c-apps/oils_execsql.c b/Open-ILS/src/c-apps/oils_execsql.c
index 4c10ddc..7491dd3 100644
--- a/Open-ILS/src/c-apps/oils_execsql.c
+++ b/Open-ILS/src/c-apps/oils_execsql.c
@@ -166,7 +166,7 @@ static jsonObject* get_date_column( dbi_result result, int col_idx ) {
 		gmtime_r( &timestamp, &gmdt );
 		strftime( timestring, sizeof( timestring ), "%T", &gmdt );
 	} else if( !( attr & DBI_DATETIME_TIME )) {
-		localtime_r( &timestamp, &gmdt );
+		gmtime_r( &timestamp, &gmdt );
 		strftime( timestring, sizeof( timestring ), "%F", &gmdt );
 	} else {
 		localtime_r( &timestamp, &gmdt );
diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c
index 0d3205c..8169f42 100644
--- a/Open-ILS/src/c-apps/oils_sql.c
+++ b/Open-ILS/src/c-apps/oils_sql.c
@@ -6683,7 +6683,7 @@ static jsonObject* oilsMakeFieldmapperFromResult( dbi_result result, osrfHash* m
 						gmtime_r( &_tmp_dt, &gmdt );
 						strftime( dt_string, sizeof( dt_string ), "%T", &gmdt );
 					} else if( !( attr & DBI_DATETIME_TIME )) {
-						localtime_r( &_tmp_dt, &gmdt );
+						gmtime_r( &_tmp_dt, &gmdt );
 						strftime( dt_string, sizeof( dt_string ), "%04Y-%m-%d", &gmdt );
 					} else {
 						localtime_r( &_tmp_dt, &gmdt );
@@ -6769,7 +6769,7 @@ static jsonObject* oilsMakeJSONFromResult( dbi_result result ) {
 						gmtime_r( &_tmp_dt, &gmdt );
 						strftime( dt_string, sizeof( dt_string ), "%T", &gmdt );
 					} else if( !( attr & DBI_DATETIME_TIME )) {
-						localtime_r( &_tmp_dt, &gmdt );
+						gmtime_r( &_tmp_dt, &gmdt );
 						strftime( dt_string, sizeof( dt_string ), "%04Y-%m-%d", &gmdt );
 					} else {
 						localtime_r( &_tmp_dt, &gmdt );

commit e174b43ef179828e32f60e71b4c56b691e3e85e0
Author: Bill Erickson <berickxx at gmail.com>
Date:   Wed Sep 30 12:13:21 2015 -0400

    LP#838525 DoB as date PGTAP test
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/t/dob-as-date.pg b/Open-ILS/src/sql/Pg/t/dob-as-date.pg
new file mode 100644
index 0000000..a1f726f
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/dob-as-date.pg
@@ -0,0 +1,38 @@
+BEGIN;
+
+SELECT plan(5);
+
+SELECT col_type_is('actor', 'usr', 'dob', 'date', 'Check dob column type');
+
+SELECT is(
+    (SELECT (
+        '2011-02-28 23:00:00-05'::timestamptz + '3 hours'::interval)::date),
+    '2011-03-01',
+    'Confirming date translation on hour-23 dates'
+);
+
+SELECT is(
+    (SELECT dob FROM actor.usr WHERE id = 1),
+    '1979-01-22', -- DoB of admin user
+    'Checking admin default dob'
+);
+
+UPDATE actor.usr SET dob = '2011-03-01 00:00:00-10' WHERE id = 1;
+
+SELECT is(
+    (SELECT dob FROM actor.usr WHERE id = 1),
+    '2011-03-01',
+    'Date truncation with timezone v1'
+);
+
+UPDATE actor.usr SET dob = '2011-06-01 00:00:00+10' WHERE id = 1;
+
+SELECT is(
+    (SELECT dob FROM actor.usr WHERE id = 1),
+    '2011-06-01', 
+    'Date truncation with timezone v2'
+);
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;

commit 71592293e1be843e4f478f98c3899e068f699e6b
Author: Bill Erickson <berickxx at gmail.com>
Date:   Tue Sep 29 12:10:31 2015 -0400

    LP#838525 Store date of birth as SQL DATE type
    
    Upgrade script translates DoB ahead 3 hours before translating to DATE
    (from TIMESTAMPTZ) to ensure dates stored in alternate daylight savings
    TZ (e.g. -05 vs. -04) are translated to the proper date.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql
index 447d595..c023977 100644
--- a/Open-ILS/src/sql/Pg/005.schema.actors.sql
+++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql
@@ -49,7 +49,7 @@ CREATE TABLE actor.usr (
 	mailing_address		INT,
 	billing_address		INT,
 	home_ou			INT				NOT NULL,
-	dob			TIMESTAMP WITH TIME ZONE,
+	dob			DATE,
 	active			BOOL				NOT NULL DEFAULT TRUE,
 	master_account		BOOL				NOT NULL DEFAULT FALSE,
 	super_user		BOOL				NOT NULL DEFAULT FALSE,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dob-as-date.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dob-as-date.sql
new file mode 100644
index 0000000..8953156
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dob-as-date.sql
@@ -0,0 +1,161 @@
+BEGIN;
+
+DROP VIEW action.all_circulation;
+DROP VIEW reporter.demographic;
+DROP VIEW auditor.actor_usr_lifecycle;
+DROP VIEW action.all_hold_request;
+
+ALTER TABLE actor.usr ALTER dob TYPE date USING (dob + '3 hours')::date;
+
+CREATE VIEW auditor.actor_usr_lifecycle AS
+     SELECT (-1) AS audit_id, now() AS audit_time,
+        '-'::text AS audit_action, (-1) AS audit_user, (-1) AS audit_ws,
+        usr.id, usr.card, usr.profile, usr.usrname, usr.email, usr.passwd,
+        usr.standing, usr.ident_type, usr.ident_value, usr.ident_type2,
+        usr.ident_value2, usr.net_access_level, usr.photo_url, usr.prefix,
+        usr.first_given_name, usr.second_given_name, usr.family_name,
+        usr.suffix, usr.alias, usr.day_phone, usr.evening_phone,
+        usr.other_phone, usr.mailing_address, usr.billing_address,
+        usr.home_ou, usr.dob, usr.active, usr.master_account,
+        usr.super_user, usr.barred, usr.deleted, usr.juvenile, usr.usrgroup,
+        usr.claims_returned_count, usr.credit_forward_balance,
+        usr.last_xact_id, usr.alert_message, usr.create_date,
+        usr.expire_date, usr.claims_never_checked_out_count,
+        usr.last_update_time
+       FROM actor.usr
+UNION ALL
+     SELECT actor_usr_history.audit_id, actor_usr_history.audit_time,
+        actor_usr_history.audit_action, actor_usr_history.audit_user,
+        actor_usr_history.audit_ws, actor_usr_history.id,
+        actor_usr_history.card, actor_usr_history.profile,
+        actor_usr_history.usrname, actor_usr_history.email,
+        actor_usr_history.passwd, actor_usr_history.standing,
+        actor_usr_history.ident_type, actor_usr_history.ident_value,
+        actor_usr_history.ident_type2, actor_usr_history.ident_value2,
+        actor_usr_history.net_access_level, actor_usr_history.photo_url,
+        actor_usr_history.prefix, actor_usr_history.first_given_name,
+        actor_usr_history.second_given_name, actor_usr_history.family_name,
+        actor_usr_history.suffix, actor_usr_history.alias,
+        actor_usr_history.day_phone, actor_usr_history.evening_phone,
+        actor_usr_history.other_phone, actor_usr_history.mailing_address,
+        actor_usr_history.billing_address, actor_usr_history.home_ou,
+        actor_usr_history.dob, actor_usr_history.active,
+        actor_usr_history.master_account, actor_usr_history.super_user,
+        actor_usr_history.barred, actor_usr_history.deleted,
+        actor_usr_history.juvenile, actor_usr_history.usrgroup,
+        actor_usr_history.claims_returned_count,
+        actor_usr_history.credit_forward_balance,
+        actor_usr_history.last_xact_id, actor_usr_history.alert_message,
+        actor_usr_history.create_date, actor_usr_history.expire_date,
+        actor_usr_history.claims_never_checked_out_count,
+        actor_usr_history.last_update_time
+       FROM auditor.actor_usr_history;
+
+CREATE VIEW reporter.demographic AS
+    SELECT u.id, u.dob,
+        CASE
+            WHEN u.dob IS NULL THEN 'Adult'::text
+            WHEN age(u.dob) > '18 years'::interval THEN 'Adult'::text
+            ELSE 'Juvenile'::text
+        END AS general_division
+    FROM actor.usr u;
+
+CREATE VIEW action.all_circulation AS
+         SELECT aged_circulation.id, aged_circulation.usr_post_code,
+            aged_circulation.usr_home_ou, aged_circulation.usr_profile,
+            aged_circulation.usr_birth_year, aged_circulation.copy_call_number,
+            aged_circulation.copy_location, aged_circulation.copy_owning_lib,
+            aged_circulation.copy_circ_lib, aged_circulation.copy_bib_record,
+            aged_circulation.xact_start, aged_circulation.xact_finish,
+            aged_circulation.target_copy, aged_circulation.circ_lib,
+            aged_circulation.circ_staff, aged_circulation.checkin_staff,
+            aged_circulation.checkin_lib, aged_circulation.renewal_remaining,
+            aged_circulation.grace_period, aged_circulation.due_date,
+            aged_circulation.stop_fines_time, aged_circulation.checkin_time,
+            aged_circulation.create_time, aged_circulation.duration,
+            aged_circulation.fine_interval, aged_circulation.recurring_fine,
+            aged_circulation.max_fine, aged_circulation.phone_renewal,
+            aged_circulation.desk_renewal, aged_circulation.opac_renewal,
+            aged_circulation.duration_rule,
+            aged_circulation.recurring_fine_rule,
+            aged_circulation.max_fine_rule, aged_circulation.stop_fines,
+            aged_circulation.workstation, aged_circulation.checkin_workstation,
+            aged_circulation.checkin_scan_time, aged_circulation.parent_circ
+           FROM action.aged_circulation
+UNION ALL
+         SELECT DISTINCT circ.id,
+            COALESCE(a.post_code, b.post_code) AS usr_post_code,
+            p.home_ou AS usr_home_ou, p.profile AS usr_profile,
+            date_part('year'::text, p.dob)::integer AS usr_birth_year,
+            cp.call_number AS copy_call_number, circ.copy_location,
+            cn.owning_lib AS copy_owning_lib, cp.circ_lib AS copy_circ_lib,
+            cn.record AS copy_bib_record, circ.xact_start, circ.xact_finish,
+            circ.target_copy, circ.circ_lib, circ.circ_staff,
+            circ.checkin_staff, circ.checkin_lib, circ.renewal_remaining,
+            circ.grace_period, circ.due_date, circ.stop_fines_time,
+            circ.checkin_time, circ.create_time, circ.duration,
+            circ.fine_interval, circ.recurring_fine, circ.max_fine,
+            circ.phone_renewal, circ.desk_renewal, circ.opac_renewal,
+            circ.duration_rule, circ.recurring_fine_rule, circ.max_fine_rule,
+            circ.stop_fines, circ.workstation, circ.checkin_workstation,
+            circ.checkin_scan_time, circ.parent_circ
+           FROM action.circulation circ
+      JOIN asset.copy cp ON circ.target_copy = cp.id
+   JOIN asset.call_number cn ON cp.call_number = cn.id
+   JOIN actor.usr p ON circ.usr = p.id
+   LEFT JOIN actor.usr_address a ON p.mailing_address = a.id
+   LEFT JOIN actor.usr_address b ON p.billing_address = b.id;
+
+CREATE OR REPLACE VIEW action.all_hold_request AS
+         SELECT DISTINCT COALESCE(a.post_code, b.post_code) AS usr_post_code,
+            p.home_ou AS usr_home_ou, p.profile AS usr_profile,
+            date_part('year'::text, p.dob)::integer AS usr_birth_year,
+            ahr.requestor <> ahr.usr AS staff_placed, ahr.id, ahr.request_time,
+            ahr.capture_time, ahr.fulfillment_time, ahr.checkin_time,
+            ahr.return_time, ahr.prev_check_time, ahr.expire_time,
+            ahr.cancel_time, ahr.cancel_cause, ahr.cancel_note, ahr.target,
+            ahr.current_copy, ahr.fulfillment_staff, ahr.fulfillment_lib,
+            ahr.request_lib, ahr.selection_ou, ahr.selection_depth,
+            ahr.pickup_lib, ahr.hold_type, ahr.holdable_formats,
+                CASE
+                    WHEN ahr.phone_notify IS NULL THEN false
+                    WHEN ahr.phone_notify = ''::text THEN false
+                    ELSE true
+                END AS phone_notify,
+            ahr.email_notify,
+                CASE
+                    WHEN ahr.sms_notify IS NULL THEN false
+                    WHEN ahr.sms_notify = ''::text THEN false
+                    ELSE true
+                END AS sms_notify,
+            ahr.frozen, ahr.thaw_date, ahr.shelf_time, ahr.cut_in_line,
+            ahr.mint_condition, ahr.shelf_expire_time, ahr.current_shelf_lib,
+            ahr.behind_desk
+           FROM action.hold_request ahr
+      JOIN actor.usr p ON ahr.usr = p.id
+   LEFT JOIN actor.usr_address a ON p.mailing_address = a.id
+   LEFT JOIN actor.usr_address b ON p.billing_address = b.id
+UNION ALL
+         SELECT aged_hold_request.usr_post_code, aged_hold_request.usr_home_ou,
+            aged_hold_request.usr_profile, aged_hold_request.usr_birth_year,
+            aged_hold_request.staff_placed, aged_hold_request.id,
+            aged_hold_request.request_time, aged_hold_request.capture_time,
+            aged_hold_request.fulfillment_time, aged_hold_request.checkin_time,
+            aged_hold_request.return_time, aged_hold_request.prev_check_time,
+            aged_hold_request.expire_time, aged_hold_request.cancel_time,
+            aged_hold_request.cancel_cause, aged_hold_request.cancel_note,
+            aged_hold_request.target, aged_hold_request.current_copy,
+            aged_hold_request.fulfillment_staff,
+            aged_hold_request.fulfillment_lib, aged_hold_request.request_lib,
+            aged_hold_request.selection_ou, aged_hold_request.selection_depth,
+            aged_hold_request.pickup_lib, aged_hold_request.hold_type,
+            aged_hold_request.holdable_formats, aged_hold_request.phone_notify,
+            aged_hold_request.email_notify, aged_hold_request.sms_notify,
+            aged_hold_request.frozen, aged_hold_request.thaw_date,
+            aged_hold_request.shelf_time, aged_hold_request.cut_in_line,
+            aged_hold_request.mint_condition,
+            aged_hold_request.shelf_expire_time,
+            aged_hold_request.current_shelf_lib, aged_hold_request.behind_desk
+           FROM action.aged_hold_request;
+
+COMMIT;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/c-apps/oils_execsql.c                 |    2 +-
 Open-ILS/src/c-apps/oils_sql.c                     |    4 +-
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/005.schema.actors.sql          |    2 +-
 Open-ILS/src/sql/Pg/t/lp838525-dob-as-date.pg      |   38 +++++
 .../src/sql/Pg/upgrade/0945.schema.dob-as-date.sql |  163 ++++++++++++++++++++
 6 files changed, 206 insertions(+), 5 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/t/lp838525-dob-as-date.pg
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0945.schema.dob-as-date.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list