cache; $month = array( 1 => 'Январь', 2 => 'Февраль', 3 => 'Март', 4 => 'Апрель', 5 => 'Май', 6 => 'Июнь', 7 => 'Июль', 8 => 'Август', 9 => 'Сентябрь', 10 => 'Октябрь', 11 => 'Ноябрь', 12 => 'Декабрь' ); $week = 1; if (Yii::$app->request->isGet){ $week = Yii::$app->request->get('week'); $week = $week?$week:'1'; } $start = strtotime( date("Y-m-d", strtotime( date("Y-m-d")." $week weeks ago")) ); $mstart = date("Y-m-d", strtotime(" monday this week", $start )); $mend = date("Y-m-d", strtotime( " sunday this week", $start )); $this->title = "Контентная аналитика ".$mstart; $this->params['breadcrumbs'][] = ['label' => $this->title, 'url' => ['index']]; $cache = Yii::$app->cache; $ckey = "w page:".md5("$mstart $mend"); if( $res = $cache->get($ckey) ){ $r = unserialize($res); }else{ $r = $model->YGetByTime(['date1'=>$mstart, 'date2'=>$mend,'dimensions'=>'ym:s:publisherArticle','metrics'=>'ym:s:publisherviews','filters'=>'(ym:s:publisherArticle!n)','sort'=>'-ym:s:publisherviews','limit'=>20, 'top_keys'=>20]); if( $r ){ $cache->set($ckey, serialize( $r )); } } $ckey = "w rubric:".md5("$mstart $mend"); if( $res = $cache->get($ckey) ){ $r1 = unserialize($res); }else{ $r1 = $model->YGetByTime(['date1'=>$mstart, 'date2'=>$mend,'dimensions'=>'ym:s:publisherArticleRubric, ym:s:publisherArticleRubric2','metrics'=>'ym:s:publisherviews','filters'=>'(ym:s:publisherArticle!n)','sort'=>'-ym:s:publisherviews','limit'=>20, 'top_keys'=>20]); if( $r ){ $cache->set($ckey, serialize( $r1 )); } } $ckey = "w topic:".md5("$mstart $mend"); if( $res = $cache->get($ckey) ){ $r2 = unserialize($res); }else{ $r2 = $model->YGetByTime(['date1'=>$mstart, 'date2'=>$mend,'dimensions'=>'ym:s:publisherArticleTopic','metrics'=>'ym:s:publisherviews','filters'=>'(ym:s:publisherArticle!n)','sort'=>'-ym:s:publisherviews','limit'=>20, 'top_keys'=>20]); if( $r ){ $cache->set($ckey, serialize( $r2 )); } } $ckey = "w tn:".md5("$mstart $mend"); if( $res = $cache->get($ckey) ){ $tncount = unserialize($res); }else{ $rubricInNews = Yii::$app->db->createCommand("select t.topic_id tid, tn.title, count(news_id) c FROM `news` n, `news_topic_relation` t, `news_topic` tn WHERE `dt_pub` BETWEEN '".$mstart."' AND '".$mend."' and n.active = 'Y' and tn.active = 1 and n.id=news_id and tn.id=t.topic_id group by t.topic_id order by c desc")->queryAll(); $tncount = []; foreach($rubricInNews as $item){ $tncount[$item['title']] = $item['c']; } $cache->set($ckey, serialize( $tncount )); } $ckey = "w tagsn:".md5("$mstart $mend"); if( $res = $cache->get($ckey) ){ $tagncount = unserialize($res); }else{ // echo "select t.topic_id tid, tn.title, count(news_id) c FROM `news` n, `tags_relation` t, `tags` tn WHERE `dt_pub` BETWEEN '".$mstart."' AND '".$mend."' and n.active = 'Y' and tn.active = 1 and n.id=news_id and tn.id=t.topic_id group by t.topic_id order by c desc"; $rubricInNews = Yii::$app->db->createCommand("select t.topic_id tid, tn.title, count(news_id) c FROM `news` n, `tags_relation` t, `tags` tn WHERE `dt_pub` BETWEEN '".$mstart."' AND '".$mend."' and n.active = 'Y' and tn.active = 1 and n.id=news_id and tn.id=t.topic_id group by t.topic_id order by c desc")->queryAll(); $tagncount = []; foreach($rubricInNews as $item){ $tagncount[$item['title']] = $item['c']; } $cache->set($ckey, serialize( $tagncount )); } //print_a($tagncount); //print_a($r2); ?>
Alert!

Прошлая неделя: -

amic.ru:
Данные amic.ru по данным яндекс метрика

ТОП Новостей за неделю

data as $item){ if( $item->dimensions[0]->url == 'http://amic.ru/' ) continue; ?> ".$item->dimensions[0]->title.""; echo ""; echo ""; echo ""; echo ""; ?>
Статья Посетителей Рубрика 1 Рубрика 2 Тэги
".$item->metrics[0][0]."".$item->dimensions[0]->rubric."".$item->dimensions[0]->rubric2."".$item->dimensions[0]->topics."

ТОП Рубрик за неделю

data as $item){ ?> dimensions[0]->name])?'':'раздел/сюжет'; echo ""; echo ""; if( isset($tncount[$item->dimensions[0]->name]) ){ echo ""; }else{ echo ""; } ?>
Рубрика Посетителей публикаций в рубрике
".$item->dimensions[0]->name." $s".$item->metrics[0][0]."".$tncount[$item->dimensions[0]->name]."

ТОП Тэгов за неделю

data as $item){ ?> ".$item->dimensions[0]->name.""; echo ""; if( isset($tagncount[$item->dimensions[0]->name]) ){ echo ""; $perc = round($item->metrics[0][0]/$tagncount[$item->dimensions[0]->name]); echo ""; $tnp1[$item->dimensions[0]->name] = $perc; }else{ echo ""; echo ""; } ?>
Тэги Посетителей Новостей с тэгом относительно публикаций
".$item->metrics[0][0]."".$tagncount[$item->dimensions[0]->name]."".round($perc,1)."

ТОП Рубрик за неделю относительно количества публикаций

data as $item){ if( isset($tncount[$item->dimensions[0]->name]) ){ $perc = round($item->metrics[0][0]/$tncount[$item->dimensions[0]->name],1).""; $tnp[$item->dimensions[0]->name] = $perc; } } $sum = array_sum($tnp); arsort($tnp); foreach($tnp as $key=>$item){ ?> ".$key.""; echo ""; ?>
Рубрика Посетителей на публикацию
".$item."

Эффективность статей по рубрикам

Эффективность статей по тэгам

$item){ $srubc .= round($item*100/$sum,1).','; $srub .= '"'.$key.' '. round($item*100/$sum,1).'%",'; $r = array_pop($bga); if( $r ){ $bgc .= "'".$r."',"; }else{ $bgc .= "'#".dechex(rand(10,255)).dechex(rand(10,255)).dechex(rand(1,255))."',"; } } ?> $item){ $srubc1 .= round($item*100/$sum1,1).','; $srub1 .= '"'.$key.' '. round($item*100/$sum1,1).'%",'; $r = array_pop($bga1); if( $r ){ $bgc1 .= "'".$r."',"; }else{ $bgc1 .= "'#".dechex(rand(10,255)).dechex(rand(10,255)).dechex(rand(1,255))."',"; } } ?>