irc::logger::update_log (public)

 irc::logger::update_log -date date -package_id package_id

Defined in packages/irc-logger/tcl/irc-logger-procs.tcl

Check the IRC log of the passed date associated with package_id. Transform the RDF log to HTML if the log has changed since the last time this proc was run. Then place the HTML log in an ETP page of the ETP instance that IRC logger is mounted under. The ETP page has the name of passed date.

Switches:
-date (required)
The date in YYYY-MM-DD format to get the IRC log of.
-package_id (required)
The package_id of the mounted IRC logger instance to get the log for.
Returns:
none
Error:
Write warning messages to the log were necessary.
Author:
Bart Teeuwisse <bart.teeuwisse@thecodemill.biz>
Created:
2003-01-27

Partial Call Graph (max 5 caller/called nodes):
%3 irc::logger::scheduled_update irc::logger::scheduled_update (public) irc::logger::update_log irc::logger::update_log irc::logger::scheduled_update->irc::logger::update_log packages/irc-logger/www/admin/update.tcl packages/irc-logger/ www/admin/update.tcl packages/irc-logger/www/admin/update.tcl->irc::logger::update_log acs_package_root_dir acs_package_root_dir (public) irc::logger::update_log->acs_package_root_dir apm_package_key_from_id apm_package_key_from_id (public) irc::logger::update_log->apm_package_key_from_id apm_package_url_from_id apm_package_url_from_id (public) irc::logger::update_log->apm_package_url_from_id db_0or1row db_0or1row (public) irc::logger::update_log->db_0or1row db_dml db_dml (public) irc::logger::update_log->db_dml

Testcases:
No testcase defined.
Source code:

    # Check for an ETP parent node.

    set logger_url [apm_package_url_from_id $package_id]
    if {![empty_string_p $logger_url]} {
        set parent_package_id [site_node::get_object_id  -node_id [site_node::get_parent_id  -node_id [site_node::get_node_id  -url $logger_url]]]
        set parent_package_key [apm_package_key_from_id $parent_package_id]
        if {[string equal $parent_package_key "edit-this-page"]} {

            # Get the RDF log for today.

            set irc_rdf_log [irc::logger::get_log  -date $date  -package_id $package_id]
            if {![empty_string_p $irc_rdf_log]} {
                
                # Check if today's log has been modified. 

                if {[file mtime $irc_rdf_log] > [expr [clock seconds] - [parameter::get  -parameter irc_log_interval  -package_id $package_id  -default 600]]} {
                    
                    # Transform the RDF log to HTML.

                    set irc_html_log [irc::logger::apply_xslt  -rdf_log $irc_rdf_log  -xsl_style [parameter::get  -parameter xsl_stylesheet  -package_id $package_id  -default "[acs_package_root_dir [apm_package_key_from_id $package_id]]/data/default.xsl"]  -package_id $package_id]

                    if {![empty_string_p $irc_html_log]} {
                        
                        # The transformation was succesful. Time to create
                        # or update the ETP page.

                        set irc_channel_name "[parameter::get  -parameter irc_channel_name  -package_id $package_id  -default ""]"
                        set log_latest_revision_id [etp::get_latest_revision_id $parent_package_id $date]
                        set content_type [etp::get_content_type]
                        if {[empty_string_p $log_latest_revision_id]} {

                            # Create a new ETP page for the log.

                            db_exec_plsql page_create {}
                set log_live_revision_id [etp::get_live_revision_id $parent_package_id $date]

                # Rotate the logs so that the new log is
                # on top.

                irc::logger::rotate_logs -package_id $parent_package_id

                # Symlink 'current' to the latest log.

                set log_url "[site_node::get_url -node_id $parent_package_id]$date"
                if {![db_0or1row get_extlink {}]} {

                # Create a 'current' symlink to the
                # new log. As ETP symlinks don't
                # support labels the link is created
                # as an ETP extlink which do support
                # labels and descriptions.

                set link_label "current"
                set link_description "Current $irc_channel_name conversation log"
                db_exec_plsql create_extlink {}

                # Rotate the symlink to the top of the list.

                irc::logger::rotate_logs -package_id $parent_package_id -all

                } else {

                # Point the 'current' symlink to the new log.

                db_dml update_extlink {}

                }
                        } else {
                set log_live_revision_id [etp::get_live_revision_id $parent_package_id $date]
            }

                        # The update the existing ETP page for the log.
                        
                        set log_description "Conversation log of $irc_channel_name of $date"
                        db_dml update_revision {}

                        # Flush the cached page from memory

                        util_memoize_flush "etp::get_pa $parent_package_id $date $content_type"
                    }
                }
            }    
        } else {
            ns_log warning "irc::logger::update_log - IRC logger $logger_url is not directly mounted under an ETP instance but rather $parent_package_key"
        }
    } else {
        ns_log warning "irc::logger::update_log - IRC logger $package_id has been unmounted"
    }
XQL Not present:
Oracle
Generic XQL file:
<fullquery name="irc::logger::update_log.get_extlink">
    <querytext>
      select extlink_id 
      from cr_extlinks e, cr_items i, cr_folders f
      where i.item_id = e.extlink_id
      and i.parent_id = f.folder_id
      and f.package_id = :parent_package_id
      and e.label = 'current'
    </querytext>
</fullquery>

<fullquery name="irc::logger::update_log.update_extlink">
    <querytext>
      update cr_extlinks
      set url = :log_url
      where extlink_id = :extlink_id
    </querytext>
</fullquery>

<fullquery name="irc::logger::update_log.update_revision">
    <querytext>
      update cr_revisions 
      set description = :log_description, content = :irc_html_log, mime_type = 'text/html'
      where revision_id = :log_live_revision_id
    </querytext>
</fullquery>
packages/irc-logger/tcl/irc-logger-procs.xql

PostgreSQL XQL file:
<fullquery name="irc::logger::update_log.page_create">
    <querytext>
      select etp__create_page(:parent_package_id, :date, :date, :content_type)
    </querytext>
</fullquery>

<fullquery name="irc::logger::update_log.create_extlink">
    <querytext>
      select etp__create_extlink(:parent_package_id, :log_url, :link_label, :link_description);
    </querytext>
</fullquery>
packages/irc-logger/tcl/irc-logger-procs-postgresql.xql

[ hide source ] | [ make this the default ]
Show another procedure: