Index: openacs-4/packages/acs-authentication/tcl/sync-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/sync-procs-oracle.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-authentication/tcl/sync-procs-oracle.xql 8 Sep 2003 15:59:43 -0000 1.1
+++ openacs-4/packages/acs-authentication/tcl/sync-procs-oracle.xql 9 Sep 2003 08:38:23 -0000 1.2
@@ -59,6 +59,15 @@
+
+
+
+ delete from auth_batch_jobs
+ where job_end_time < sysdate - :num_days
+
+
+
+
Index: openacs-4/packages/acs-authentication/tcl/sync-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/sync-procs-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-authentication/tcl/sync-procs-postgresql.xql 8 Sep 2003 15:59:43 -0000 1.1
+++ openacs-4/packages/acs-authentication/tcl/sync-procs-postgresql.xql 9 Sep 2003 08:38:23 -0000 1.2
@@ -58,4 +58,13 @@
+
+
+
+ delete from auth_batch_jobs
+ where job_end_time < current_timestamp - interval '$num_days days'
+
+
+
+
Index: openacs-4/packages/acs-authentication/tcl/sync-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/sync-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-authentication/tcl/sync-procs.tcl 9 Sep 2003 08:10:47 -0000 1.3
+++ openacs-4/packages/acs-authentication/tcl/sync-procs.tcl 9 Sep 2003 08:38:23 -0000 1.4
@@ -11,6 +11,11 @@
namespace eval auth::sync::job {}
+#####
+#
+# auth::sync::job namespace
+#
+#####
ad_proc -public auth::sync::job::get {
{-job_id:required}
@@ -355,22 +360,27 @@
}
+#####
+#
+# auth::sync namespace
+#
+#####
-
-
-
-ad_proc -public auth::sync::purge_jobs {} {
+ad_proc -public auth::sync::purge_jobs {
+ {-num_days ""}
+} {
Purge jobs that are older than KeepBatchLogDays days.
} {
- # Don't forget to also delete the cr_item referenced by the auth_batch_jobs.document column.
+ if { ![exists_and_not_null num_days] } {
+ set num_days [parameter::get_from_package_key -parameter KeepBatchLogDays -package_key "acs-authentication" -default 0]
+ }
+
+ validate_integer num_days $num_days
- # Parameter: KeepBatchLogDays - number of days to keep batch job log around. 0 = forever.
+ if { $num_days > 0 } {
+ # TODO: Don't forget to also delete the cr_item referenced by the auth_batch_jobs.document column.
- # TODO
+ db_dml purge_jobs {}
+ }
}
-
-
-
-
-
Index: openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl 9 Sep 2003 08:10:47 -0000 1.3
+++ openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl 9 Sep 2003 08:38:23 -0000 1.4
@@ -48,24 +48,37 @@
-user_id [ad_conn user_id] \
-message "A problem" \
-element_messages ""
-
-
+
+
# End job
array set job [auth::sync::job::end -job_id $job_id]
aa_true "Elapsed time less than 30 seconds" [expr $job(run_time_seconds) < 30]
-
+
aa_log "Elapsed time: $job(run_time_seconds) seconds"
-
+
aa_false "Not interactive" [template::util::is_true $job(interactive_p)]
-
+
aa_equals "Number of actions" $job(num_actions) 2
-
+
aa_equals "Number of problems" $job(num_problems) 1
aa_false "Log URL non-empty" [empty_string_p $job(log_url)]
+ # Purge not deleting the job
+ auth::sync::purge_jobs \
+ -num_days 1
+ aa_equals "Job still exists" [db_string job_exists_p { select count(*) from auth_batch_job_entries where job_id = :job_id }] 2
+
+ # Tricking it into deleting the job
+ aa_log "Updating the job end time"
+ db_dml update_job { update auth_batch_jobs set job_end_time = to_date('1974-03-27', 'YYYY-MM-DD') where job_id = :job_id }
+ auth::sync::purge_jobs \
+ -num_days 1
+
+ aa_equals "Job has been purged" [db_string job_exists_p { select count(*) from auth_batch_job_entries where job_id = :job_id }] 0
+
}
}