Exemple #1
0
 /**
  * Calculate dashboard summary results
  * @author Ruslan Ushakov
  */
 function calculate_dashboard_summary_results($date_of_upload = '')
 {
     $this->load->model('ranking_model');
     $this->load->model('sites_model');
     $this->load->model('ranking_summary_model');
     $sites_list = $this->ranking_model->getAllRankingSites();
     if (empty($date_of_upload)) {
         $date_of_upload = date('Y-m-d', strtotime('-1 day'));
     }
     set_time_limit(0);
     $summary_data = array();
     $count = 0;
     foreach ($sites_list as $site) {
         $brands_list = $this->ranking_summary_model->getAvailableBrandsForSite($site->id, $date_of_upload);
         foreach ($brands_list as $brand) {
             $data_prepared = $this->ranking_summary_model->getProductsBySearchCriteriaQuery($site->id, $date_of_upload, 0, $brand->id);
             if (!empty($data_prepared)) {
                 $count_results = array();
                 foreach ($data_prepared as $data) {
                     if (!array_key_exists($data->term_id, $count_results)) {
                         $count_results[$data->term_id] = array();
                     }
                     $count_results[$data->term_id][] = $data;
                 }
                 if (!empty($count_results)) {
                     foreach ($count_results as $term_id => $result) {
                         $ofp = Ranking_summary_model::get_ofp_total_count($result);
                         $other_pages = count($result) - $ofp;
                         if (!$this->ranking_summary_model->checkRankingSummaryResults($site->id, $term_id, $brand->id, $date_of_upload)) {
                             $summary_data[] = array('brand_id' => $brand->id, 'site_id' => $site->id, 'term_id' => $term_id, 'creation_date' => $date_of_upload, 'ofp_num' => $ofp, 'other_res_num' => $other_pages);
                             ++$count;
                         }
                         if (count($summary_data) == 1000) {
                             $this->ranking_summary_model->insertBatchRankingSummaryResults($summary_data);
                             $summary_data = array();
                         }
                     }
                 }
             }
         }
     }
     if (!empty($summary_data)) {
         $this->ranking_summary_model->insertBatchRankingSummaryResults($summary_data);
     }
     echo $count;
     die;
 }
Exemple #2
0
 /**
  *function GetDashboardSummary
  *@author Hermine
  **/
 public function GetDashboardSummary_post()
 {
     $this->load->model('ranking_model');
     $this->load->model('sites_model');
     $site_id = $this->input->post('site_id');
     $term_id = $this->input->post('term_id');
     $brand_id = $this->input->post('brand_id');
     $date_of_upload = $this->input->post('date_of_upload');
     $view = $this->input->post('view');
     $all_checked_checkboxes = $this->input->post('all_checked_checkboxes');
     $all_checked_brand_checkboxes = $this->input->post('all_checked_brand_checkboxes');
     $brands_groups = array();
     $brands_groups_prepared = array();
     $brands_prepared = Ranking_model::getBrandIdsFromSelectedGroups($brand_id, $all_checked_brand_checkboxes, $brands_groups);
     if (!empty($brands_groups)) {
         foreach ($brands_groups as $key => $group) {
             $group_id = (int) substr($key, 1);
             $group_obj = $this->ranking_model->getRankingBrandGroups($group_id);
             if (!empty($group_obj[0]->group_name)) {
                 $brands_groups_prepared[$group_obj[0]->group_name] = $group;
             }
         }
     }
     $this->load->model('ranking_model');
     $this->load->model('ranking_summary_model');
     $data = array();
     if ($view == 'DshSum') {
         $data = $this->ranking_summary_model->getRankingSummaryResults($site_id, $term_id, $brands_prepared, $date_of_upload);
         $data = Ranking_summary_model::getPreparedSummaryResults($data, $brand_id, $brands_groups_prepared);
     }
     $this->response($data);
 }
Exemple #3
0
 /**
  * Return data for table view Dashboard Summary
  * @return json
  * @author Ruslan Ushakov
  */
 public function getDashboardSummary()
 {
     $this->load->model('ranking_model');
     $this->load->model('sites_model');
     $this->load->model('ranking_summary_model');
     $site_id = $this->input->post('site_id');
     $term_id = $this->input->post('term_id');
     $brand_id = $this->input->post('brand_id');
     $date_of_upload = $this->input->post('date_of_upload');
     $view = $this->input->post('view');
     $all_checked_checkboxes = $this->input->post('all_checked_checkboxes');
     $all_checked_brand_checkboxes = $this->input->post('all_checked_brand_checkboxes');
     $brands_associated = Ranking_model::getBrandIdsFromSelectedGroups($brand_id, $all_checked_brand_checkboxes);
     //Issue #3042 Associate keywords/groups with selected brand
     if (!empty($brands_associated)) {
         $this->setAssociatedBrands($brands_associated);
         $this->ranking_model->setAssociatedKeywords($brands_associated, $all_checked_checkboxes);
     }
     $brands_groups = array();
     $brands_groups_prepared = array();
     $brands_prepared = Ranking_model::getBrandIdsFromSelectedGroups($brand_id, $all_checked_brand_checkboxes, $brands_groups);
     if (!empty($brands_groups)) {
         foreach ($brands_groups as $key => $group) {
             $group_id = (int) substr($key, 1);
             $group_obj = $this->ranking_model->getRankingBrandGroups($group_id);
             if (!empty($group_obj[0]->group_name)) {
                 $brands_groups_prepared[$group_obj[0]->group_name] = $group;
             }
         }
     }
     $data = array();
     if ($view == 'DshSum') {
         $data = $this->ranking_summary_model->getRankingSummaryResults($site_id, $term_id, $brands_prepared, $date_of_upload);
         $data = Ranking_summary_model::getPreparedSummaryResults($data, $brand_id, $brands_groups_prepared);
     }
     $this->output->set_content_type('application/json')->set_output(json_encode($data));
 }