From 98d1254a4f36390cca3d0eeef5c402d191c25678 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Mon, 18 Jun 2012 12:52:04 -0400 Subject: [PATCH] Purge Circulations: Skip partially complete chains Billings in earlier portions of the chain may leave them open. Thus, look for any circulations in the chain with a null xact_finish. Signed-off-by: Thomas Berezansky Signed-off-by: Jason Stephenson --- Open-ILS/src/sql/Pg/090.schema.action.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index c3f2814f04..293aafbdc9 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -987,6 +987,7 @@ DECLARE purge_position INT; count_purged INT; + num_incomplete INT; BEGIN count_purged := 0; @@ -1022,7 +1023,8 @@ BEGIN EXIT WHEN target_acp.total_real_circs - purge_position <= org_keep_count; SELECT * INTO circ_chain_tail FROM action.circ_chain(circ_chain_head.id) ORDER BY xact_start DESC LIMIT 1; - EXIT WHEN circ_chain_tail.xact_finish IS NULL; + SELECT COUNT(CASE WHEN xact_finish IS NULL THEN 1 ELSE NULL END) INTO num_incomplete FROM action.circ_chain(circ_chain_head.id); + EXIT WHEN circ_chain_tail.xact_finish IS NULL OR num_incomplete > 0; -- Now get the user settings, if any, to block purging if the user wants to keep more circs usr_keep_age.value := NULL; -- 2.43.2