Index: openacs-4/packages/rss-support/sql/postgresql/rss-generation-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/sql/postgresql/rss-generation-create.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/rss-support/sql/postgresql/rss-generation-create.sql 19 Nov 2001 04:02:28 -0000 1.6 +++ openacs-4/packages/rss-support/sql/postgresql/rss-generation-create.sql 30 Nov 2001 05:56:37 -0000 1.7 @@ -115,6 +115,9 @@ constraint rss_gen_subscrs_timeout_nn not null, lastbuild timestamp, + last_ttb integer, + channel_title varchar(200), + channel_link varchar(1000), constraint rss_gen_subscrs_impl_con_un unique (impl_id,summary_context_id) ); @@ -149,6 +152,18 @@ Accounting column for use by rss generation service. '; +comment on column rss_gen_subscrs.last_ttb is ' + Another accounting column. The last time to build (in seconds). +'; + +comment on column rss_gen_subscrs.channel_title is ' + Used for display purposes. +'; + +comment on column rss_gen_subscrs.channel_link is ' + Used for display purposes. +'; + create function rss_gen_subscr__new (integer,integer,varchar,integer,timestamp,varchar,timestamp,integer,varchar,integer) returns integer as ' declare Index: openacs-4/packages/rss-support/tcl/rss-generation-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/tcl/rss-generation-init.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/rss-support/tcl/rss-generation-init.tcl 11 Nov 2001 05:35:21 -0000 1.1 +++ openacs-4/packages/rss-support/tcl/rss-generation-init.tcl 30 Nov 2001 05:56:37 -0000 1.2 @@ -1 +1 @@ -ad_schedule_proc 1800 rss_gen_service \ No newline at end of file +ad_schedule_proc 1800 rss_gen_service Index: openacs-4/packages/rss-support/tcl/rss-generation-service-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/tcl/rss-generation-service-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/rss-support/tcl/rss-generation-service-procs.tcl 11 Nov 2001 05:35:21 -0000 1.5 +++ openacs-4/packages/rss-support/tcl/rss-generation-service-procs.tcl 30 Nov 2001 05:56:37 -0000 1.6 @@ -9,9 +9,9 @@ db_foreach timed_out_subscriptions { select r.subscr_id, - i.impl_name, - r.summary_context_id, r.timeout, + r.summary_context_id, + i.impl_name, case when r.lastbuild = null then 0 else date_part('epoch',r.lastbuild) @@ -26,34 +26,67 @@ $summary_context_id $impl_name] if { $lastupdate > $lastbuild } { # Old report is stale. Build a new one. - set datasource [acs_sc_call RssGenerationSubscriber datasource \ - $summary_context_id $impl_name] - set args "" - foreach {name val} $datasource { - append args "-$name \"$val\" " - } - set xml [apply rss_gen $args] - set report_dir [ns_info pageroot]/[ad_parameter -package_id [rss_package_id] RssGenOutputDirectory rss-support rss]/$impl_name/${summary_context_id} + rss_gen_report $subscr_id + incr n + } + } - # Create directory if needed. - rss_assert_dir $report_dir + ns_log Debug "rss_gen_service: built $n reports" - # Write report. - set fh [open $report_dir/rss.xml w] - puts $fh $xml - close $fh +} - db_dml update_timestamp { - update rss_gen_subscrs - set lastbuild = now() - where subscr_id = :subscr_id - } - incr n +ad_proc -private rss_gen_report subscr_id { +
+    # Build a report, write it out, log it.
+    
+} { + set start [clock seconds] + + db_1row subscr_info { + select i.impl_name, + r.summary_context_id + from acs_sc_impls i, + rss_gen_subscrs r + where r.subscr_id = :subscr_id + and i.impl_id = r.impl_id + } + + set datasource [acs_sc_call RssGenerationSubscriber datasource \ + $summary_context_id $impl_name] + set args "" + foreach {name val} $datasource { + append args "-$name \"$val\" " + if { [lsearch [list channel_link channel_title] $name] >= 0 } { + set $name $val } } + set xml [apply rss_gen $args] + set report_dir [ns_info pageroot]/[ad_parameter -package_id [rss_package_id] RssGenOutputDirectory rss-support rss]/$impl_name/${summary_context_id} - ns_log Debug "rss_gen_service: built $n reports" + # Create directory if needed. + rss_assert_dir $report_dir + # Write report. + set fh [open $report_dir/rss.xml w] + puts $fh $xml + close $fh + + # Copy some useful display information into the + # subscriptions table. + set extra_sql "" + foreach col [list channel_title channel_link] { + if [info exists $col] { + append extra_sql ", $col = :$col" + } + } + + set last_ttb [expr [clock seconds] - $start] + db_dml update_timestamp " + update rss_gen_subscrs + set lastbuild = now(), + last_ttb = :last_ttb $extra_sql + where subscr_id = :subscr_id + " } ad_proc -private rss_assert_dir path { Index: openacs-4/packages/rss-support/www/subscr-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/www/subscr-ae.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/rss-support/www/subscr-ae.tcl 19 Nov 2001 04:02:28 -0000 1.2 +++ openacs-4/packages/rss-support/www/subscr-ae.tcl 30 Nov 2001 05:56:37 -0000 1.3 @@ -45,7 +45,9 @@ db_1row subscr_info { select impl_id, summary_context_id, - timeout + timeout, + channel_title, + channel_link from rss_gen_subscrs where subscr_id = :subscr_id } @@ -67,20 +69,23 @@ assistance." } -if !$meta { - set channel_title "Summary Context $summary_context_id" - set channel_link "" -} else { - # Pull out channel data by generating a summary. - # This is a convenient way to use a contracted operation - # but is not terribly efficient since we only need the channel title - # and link, and not the whole summary. - foreach {name val} [acs_sc_call RssGenerationSubscriber datasource \ - $summary_context_id $impl_name] { - if { [lsearch {channel_title channel_link} $name] >= 0 } { - set $name $val +if { [string equal $channel_title ""] || [string equal $channel_link ""] } { + if !$meta { + if [string equal $channel_title ""] { + set channel_title "Summary Context $summary_context_id" } - } + } else { + # Pull out channel data by generating a summary. + # This is a convenient way to use a contracted operation + # but is not terribly efficient since we only need the channel title + # and link, and not the whole summary. + foreach {name val} [acs_sc_call RssGenerationSubscriber datasource \ + $summary_context_id $impl_name] { + if { [lsearch {channel_title channel_link} $name] >= 0 } { + set $name $val + } + } + } } set formvars [export_form_vars subscr_id \ Index: openacs-4/packages/rss-support/www/subscr-run.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/www/subscr-run.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rss-support/www/subscr-run.tcl 30 Nov 2001 05:56:37 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Run a report for the given subscription. +} { + subscr_id:notnull,naturalnum + return_url:notnull +} + +ad_require_permission $subscr_id admin + +rss_gen_report $subscr_id + +ad_returnredirect $return_url \ No newline at end of file Index: openacs-4/packages/rss-support/www/admin/subscrs.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/www/admin/subscrs.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/rss-support/www/admin/subscrs.adp 19 Nov 2001 04:02:28 -0000 1.1 +++ openacs-4/packages/rss-support/www/admin/subscrs.adp 30 Nov 2001 05:56:37 -0000 1.2 @@ -15,12 +15,13 @@ Actions -Subscription #@subscrs.subscr_id@ +@subscrs.channel_title@@subscrs.channel_title@ @subscrs.timeout@s - - + @subscrs.lastbuild@ + @subscrs.last_ttb@ @subscrs.creator@ - edit,run,delete + edit | + run | delete Index: openacs-4/packages/rss-support/www/admin/subscrs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/www/admin/subscrs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/rss-support/www/admin/subscrs.tcl 19 Nov 2001 04:02:28 -0000 1.1 +++ openacs-4/packages/rss-support/www/admin/subscrs.tcl 30 Nov 2001 05:56:37 -0000 1.2 @@ -1,10 +1,20 @@ db_multirow subscrs get_subscrs { select s.subscr_id, s.timeout, - person__name(o.creation_user) as creator + person__name(o.creation_user) as creator, + coalesce(to_char(s.lastbuild,'YYYY-MM-DD HH24:MI:SS'),'never built') as lastbuild, + s.last_ttb, + s.channel_title, + s.channel_link from rss_gen_subscrs s, acs_objects o where o.object_id = s.subscr_id +} { + if [string equal $channel_title ""] { + set channel_title "Subscription #$subscr_id" + } } -set context_bar [ad_context_bar Subscriptions] \ No newline at end of file +set context_bar [ad_context_bar Subscriptions] + +set enc_url [ad_urlencode [ad_conn url]?[ad_conn query]] \ No newline at end of file