# # # # create_report_info() # # # # create_report_info creates a fresh report_info without any session information. The report # is read from the profile. If users_cache settings exist for this report then we override # report_info settings with specific users_cache settings. # KHP-RC, if not activated from the command line we need to check any users_cache report settings include "templates.statistics.util.create_report_info_util"; include "templates.util.get_construction_type"; subroutine(create_report_info( string session_id, string user_node_name, bool is_root_admin, string report_info_id, string profile_name, string report_name, bool is_command_line, node command_line), ( debug_message("\n\n#### create_report_info START \n"); # debug_message("\n\n" . node_as_string("command_line") . "\n"); string session_profile_path = "sessions_cache." . session_id . ".profiles." . profile_name; node report_elements = "profiles." . profile_name . ".statistics.reports." . report_name . ".report_elements"; delete_node("v.temp_report_info"); v.temp_report_info.report_name = report_name; clone_node(report_elements, "v.temp_report_info.report_elements"); node temp_report_elements = "v.temp_report_info.report_elements"; node report_element; string report_element_type; string report_element_name; string construction_type; bool is_log_detail; bool omit_parenthesized_items; string sort_by; string sort_direction; int number_of_rows; int starting_row = 1; int ending_row; string number_of_rows_as_string; string starting_row_as_string; string ending_row_as_string; int ending_row_expanded = 10; # constant value for dynamic session_paths reports int expand_paths_greater_than = -1; # constant value for dynamic session_paths reports string unique_session_paths_id; string new_table_filter_expression; string user_info_statistics_data_path; string user_info_report_elements_path; string session_report_elements_path; string page_path; if (!is_command_line) then ( user_info_statistics_data_path = "users_cache." . user_node_name . ".profiles." . profile_name . ".statistics_data"; user_info_report_elements_path = user_info_statistics_data_path . ".reports." . report_name . ".report_elements"; session_report_elements_path = session_profile_path . ".statistics_data.reports." . report_name . ".report_elements"; ); foreach report_element temp_report_elements ( report_element_name = node_name(report_element); report_element_type = @report_element{"type"}; construction_type = get_construction_type(report_element_type); if (construction_type ne "overview") then ( if (!is_command_line) then ( # # # Override report element with any users_cache settings # # if (!is_root_admin and ?(user_info_report_elements_path . "." . report_element_name)) then ( override_report_element_with_user_info_settings(report_element, user_info_report_elements_path . "." . report_element_name); ); number_of_rows = if (report_element?{"number_of_rows"}) then (@report_element{"number_of_rows"}) else (10); ending_row = number_of_rows; # debug_message("\n" . node_as_string(report_element) . "\n"); ) else ( # # # command line setup # # if (@command_line{"starting_row"} ne "") then ( starting_row = @command_line{"starting_row"}; ); if (@command_line{"ending_row"} ne "") then ( ending_row = @command_line{"ending_row"}; ) else ( ending_row = if (report_element?{"number_of_rows"}) then (@report_element{"number_of_rows"}) else (10); ); if (starting_row == 1) then ( number_of_rows = ending_row; ) else ( # Row range defined if (starting_row > ending_row) then ( starting_row = ending_row; ); number_of_rows = ending_row - starting_row + 1; ); if (@command_line{"sort_by"} ne "") then ( set_subnode_value(report_element, "sort_by", @command_line{"sort_by"}); ); if (@command_line{"sort_direction"} ne "") then ( set_subnode_value(report_element, "sort_direction", @command_line{"sort_direction"}); ); if (report_element_type eq "session_paths") then ( if (@command_line{"ending_row_expanded"} ne "") then ( ending_row_expanded = @command_line{"ending_row_expanded"}; ) else if (report_element?{"number_of_rows_expanded"}) then ( ending_row_expanded = @report_element{"number_of_rows_expanded"}; ); if (@command_line{"expand_paths_greater_than"} ne "") then ( expand_paths_greater_than = @command_line{"expand_paths_greater_than"}; ) else if (report_element?{"expand_paths_greater_than"} and (@report_element{"expand_paths_greater_than"} ne "")) then ( expand_paths_greater_than = @report_element{"expand_paths_greater_than"}; ); ) else if (report_element_type eq "session_page_paths") then ( page_path = @command_line{"page_path"}; @report_element{"page_path"} = page_path; ); ); if (construction_type ne "session_paths") then ( if (starting_row > ending_row) then ( ending_row = starting_row; ); # Note, number_of_rows, etc. should appear as string in report_info so that # it matches the format as in update_report_info(), else we get a different # report_info_id. So we use the _string variables to make sure that the numbers # are saved as string number_of_rows_as_string = number_of_rows; starting_row_as_string = starting_row; ending_row_as_string = ending_row; set_subnode_value(report_element, "number_of_rows", number_of_rows_as_string); set_subnode_value(report_element, "starting_row", starting_row_as_string); set_subnode_value(report_element, "ending_row", ending_row_as_string); # # Add custom table_filter_expression if we need to omit parenthesized items # if (construction_type eq "standard" and !is_log_detail) then ( omit_parenthesized_items = @report_element{"omit_parenthesized_items"}; if (omit_parenthesized_items) then ( # We get a new_table_filter_expression which considers an already # existing table_filter_expression in the current report element new_table_filter_expression = get_omit_parenthesized_items_table_filter_expression( session_id, is_root_admin, profile_name, report_element ); if (new_table_filter_expression ne "") then ( @report_element{"table_filter_expression"} = new_table_filter_expression; ); ); ); # # Add custom table_filter_expression if entry_pages or exit_pages. The expression # omits all pages with zero entrances or exits. # # if (report_element_type eq "entry_pages" or report_element_type eq "exit_pages") then ( # 2008-11-07 - GMF - Commenting this out because it adds *30 minutes* to report generation time of entry_page, in a 50,000-page database. # Need to rethink this, to optimize it. Use SSQL to throw out all-0 rows? # KHP 30/Nov/2008 - For your info, the problem is probably not the table filter expression but # the overview query when we get totals from an overview report. # # # table_filter_expression = get_entry_or_exit_pages_table_filter_expression( # session_id, # is_root_admin, # profile_name, # report_element, # report_element_type # ); # # if (table_filter_expression ne "") then ( # set_subnode_value(report_element, "table_filter_expression", table_filter_expression); # ); # ); ) else ( # report_element_type eq "session_paths" set_subnode_value(report_element, "number_of_rows", ending_row); set_subnode_value(report_element, "number_of_rows_expanded", ending_row_expanded); # Set expand_paths_number_of_rows if it is missing in the report element if (!(report_element?{"expand_paths_number_of_rows"})) then ( set_subnode_value(report_element, "expand_paths_number_of_rows", 10); ); set_subnode_value(report_element, "expand_paths_greater_than", expand_paths_greater_than); # Add a unique_session_paths_id so that the session_paths report element does not really become cached. # We do this because the session_paths raw report element keeps the state (expanded, row numbers, etc.) # of any server background user interaction. So each new opening of a session_paths report will result # in a new query, respectively starts over with the inital state. When we print the report, or send the report # by email we will use this raw report element with the active state. # The only purpose of the unique_session_paths_id is that we get a different checksum for the report element id # upon a fresh session_paths report request. unique_session_paths_id = now() . now_us(); set_subnode_value(report_element, "unique_session_paths_id", unique_session_paths_id); ); ); ); # # # Save the report info in sessions_cache # # string report_info_path = session_profile_path . ".report_infos." . report_info_id; clone_node("v.temp_report_info", report_info_path); save_node(report_info_path); ));