diff --git a/classes/admin/class.inbound-analytics.php b/classes/admin/class.inbound-analytics.php index f90f2d4f..d0e246f3 100644 --- a/classes/admin/class.inbound-analytics.php +++ b/classes/admin/class.inbound-analytics.php @@ -78,6 +78,12 @@ public static function load_range() { self::$dates = Inbound_Reporting_Templates::prepare_range(self::$range); + /* set correct datetime formats for db */ + $start_date = new DateTime(self::$dates['start_date']); + $end_date = new DateTime(self::$dates['end_date']); + self::$dates['start_date'] = $start_date->format('Y-m-d G:i:s'); + self::$dates['end_date'] = $end_date->format('Y-m-d G:i:s'); + return array('range' => self::$range, 'dates' => self::$dates); } @@ -296,8 +302,8 @@ public static function prepare_column_data($column, $post_id) { ); $results = Inbound_Events::get_page_views_count_by('page_id', $params); ?> - ID . '&class=Inbound_Impressions_Report&range=' . self::$range . '&tb_hide_nav=true&TB_iframe=true&width=1000&height=600'); ?>' class='thickbox inbound-thickbox' title=""> - + ID . '&class=Inbound_Impressions_Report&range=' . self::$range . '&tb_hide_nav=true&TB_iframe=true&width=1000&height=600'); ?>' class='thickbox inbound-thickbox' title="" "> + posts}.ID AND ee.datetime >= '" . self::$dates['start_date'] . "' AND datetime <= '" . self::$dates['end_date'] . "'"; + $pieces['join'] .= " RIGHT JOIN {$table_prefix}inbound_page_views ee ON ee.page_id = {$wpdb->posts}.ID AND ee.datetime >= '" . self::$dates['start_date'] . "' AND datetime <= '" . self::$dates['end_date'] . "'"; $pieces['groupby'] = " {$wpdb->posts}.ID"; - $pieces['orderby'] = "COUNT(ee.page_id) $order "; + $pieces['orderby'] = "COUNT(*) $order "; + + //print_r($pieces);exit; break; case 'inbound_visitors': - $pieces['join'] .= " LEFT JOIN (select lead_id, page_id from {$table_prefix}inbound_page_views group by lead_id) ee ON ee.page_id = {$wpdb->posts}.ID AND ee.datetime >= '" . self::$dates['start_date'] . "' AND datetime <= '" . self::$dates['end_date'] . "'"; + $pieces['join'] .= " RIGHT JOIN (select lead_id, page_id from {$table_prefix}inbound_page_views group by lead_id) ee ON ee.page_id = {$wpdb->posts}.ID AND ee.datetime >= '" . self::$dates['start_date'] . "' AND datetime <= '" . self::$dates['end_date'] . "'"; $pieces['groupby'] = " {$wpdb->posts}.ID "; - $pieces['orderby'] = "COUNT(ee.lead_id) $order "; + $pieces['orderby'] = "COUNT(*) $order "; break; case 'inbound_actions': - $pieces['join'] .= " LEFT JOIN {$table_prefix}inbound_events ee ON ee.page_id = {$wpdb->posts}.ID AND ee.datetime >= '" . self::$dates['start_date'] . "' AND datetime <= '" . self::$dates['end_date'] . "'"; + $pieces['join'] .= " RIGHT JOIN {$table_prefix}inbound_events ee ON ee.page_id = {$wpdb->posts}.ID AND ee.datetime >= '" . self::$dates['start_date'] . "' AND datetime <= '" . self::$dates['end_date'] . "'"; $pieces['groupby'] = " {$wpdb->posts}.ID"; - $pieces['orderby'] = "COUNT(ee.page_id) $order "; + $pieces['orderby'] = "COUNT(*) $order "; break; } @@ -435,4 +443,4 @@ public static function filter_profile_tabs($tabs) { } -new Inbound_Analytics(); \ No newline at end of file +new Inbound_Analytics(); diff --git a/classes/admin/class.settings.php b/classes/admin/class.settings.php index 804bc4a5..5b36b988 100644 --- a/classes/admin/class.settings.php +++ b/classes/admin/class.settings.php @@ -308,6 +308,18 @@ public static function extend_settings() { 'value' => null ) ), + array ( + 'id' => 'page-views-optimize', + 'type' => 'html', + 'label' => __( 'Database Maintenance' , 'inbound-pro' ), + 'description' => __( '' , 'inbound-pro' ), + 'callback' => array( 'Inbound_Pro_Settings' , 'display_page_view_db_options'), + 'hidden' => false, + 'reveal' => array( + 'selector' => null , + 'value' => null + ) + ), array ( 'id' => 'admin-tracking', 'type' => 'radio', @@ -793,6 +805,18 @@ public static function display_search() { + TODO/Wishlist: +