Browse Source

red stats

amic 1 year ago
parent
commit
9747556363
2 changed files with 79 additions and 8 deletions
  1. 3 2
      modules/manager/views/layouts/sidebar.php
  2. 76 6
      modules/manager/views/stats/index.php

+ 3 - 2
modules/manager/views/layouts/sidebar.php

@@ -76,7 +76,7 @@ $profile = Yii::$app->user->identity->profile;
                             ['label' => 'КД блок', 'url' => ['/manager/kd'], 'iconStyle' => 'far', 'iconClass' => 'nav-icon far fa-circle text-warning'],
                             ['label' => 'НЧ блок ', 'url' => ['/manager/nh'], 'iconStyle' => 'far', 'iconClassAdded' => 'text-danger'],
                             ['label' => 'Слайдер', 'url' => ['/manager/top-slider'], 'iconStyle' => 'far', 'iconClassAdded' => 'text-primary'],
-                            ['label' => 'Сброс кэша главной', 'url' => ['/manager/design/purge'], 'iconStyle' => 'fa', 'iconClassAdded' => 'fa-shower','badge' => '<span class="right badge badge-danger">New</span>'],
+                            ['label' => 'Сброс кэша главной', 'url' => ['/manager/design/purge'], 'iconStyle' => 'fa', 'iconClassAdded' => 'fa-shower'],
                         ]
                     ],
                     ['label' => 'Рубрики', 'icon' => 'th', 'url' => ['/manager/news/topiclist'],
@@ -108,6 +108,7 @@ $profile = Yii::$app->user->identity->profile;
                     ],
 
                     ['label' => 'Статистика', 'icon' => 'chart-pie', 'url' => ['/manager/stats/index'],
+						'badge' => '<span class="right badge badge-danger">New</span>',
                         'items' => [
                             ['label' => 'доска', 'url' => ['/manager/stats/index'], 'iconStyle' => 'fas', 'icon'=>'tachometer-alt'],
                             ['label' => 'Авторы', 'url' => ['/manager/stats/authors'], 'iconStyle' => 'far', 'icon'=>'user-circle'],
@@ -116,7 +117,7 @@ $profile = Yii::$app->user->identity->profile;
                     ],
                     ['label' => 'Персоны','icon' => 'user', 'url' => ['/manager/person/']
 					],
-                    ['label' => 'Авторы','icon' => 'user', 'url' => ['/manager/authors/'],'badge' => '<span class="right badge badge-danger">New</span>'
+                    ['label' => 'Авторы','icon' => 'user', 'url' => ['/manager/authors/'],
 					],
                     ['label' => 'пользователи', 'icon' => 'user', 'url' => ['/user/admin/index'], 'visible' => Yii::$app->user->can('view_manage_users_page'),
 						'items' => [

+ 76 - 6
modules/manager/views/stats/index.php

@@ -49,10 +49,39 @@
 	$authors = Yii::$app->db->createCommand("select e, count(e) as c from (SELECT SUBSTRING_INDEX(`editors`,',',1) as e FROM `news` WHERE `dt_pub` BETWEEN '".$b_date."' AND '".$e_date."' and active = 'Y') t where 1 group by e order by e")->queryAll();
 	$old_author_name = ['kondakov' => 'Вячеслав Кондаков*','bers'=>'Евгений Берсенёв','kuznecov' =>'Артём Кузнецов*', 'katya'=>'Екатерина Смолихина*', 'elena'=>'Елена Лепезина*', 'cherdanceva'=>'Александра Черданцева*'];
 
-	//select count(id) from news as n, news_topic_relation as tr WHERE dt_pub > "'. date("Y-m-d").'" AND dt_pub < now() and n.id = tr.news_id group by tr.topic_id'
+// рубрики заполнены
 	$rubric = Yii::$app->db->createCommand("select count(tr.topic_id) as c, nt.title as t from news as n, news_topic_relation as tr, news_topic as nt where `dt_pub` BETWEEN '".$b_date."' AND '".$e_date."' and n.active = 'Y' and n.id = tr.news_id and tr.topic_id = nt.id and nt.`active`=1 and nt.`show`='Y' group by tr.topic_id")->queryAll();
+// количество рубрик
 	$crubric = Yii::$app->db->createCommand("select count(id) as c from news_topic where `active`=1 and `show`='Y'")->queryOne();
 	$sumr = $crubric['c'];
+
+	$cnews = Yii::$app->db->createCommand("select count(id) as c  from news where `dt_pub` BETWEEN '".$b_date."' AND '".$e_date."' and active = 'Y'")->queryOne();
+	$cntnews = $cnews['c'];
+
+	$cnewsp = Yii::$app->db->createCommand("select count(id) as c  from news where `dt_pub` BETWEEN DATE_SUB('".$b_date."',  INTERVAL 1 MONTH) AND DATE_SUB('".$e_date."',  INTERVAL 1 MONTH) and active = 'Y'")->queryOne();
+	$cntnewsp = $cnewsp['c'];
+
+	$cnewsy = Yii::$app->db->createCommand("select count(id) as c  from news where `dt_pub` BETWEEN '".$y."-01-01 00:00:00' AND '".$e_date."' and active = 'Y'")->queryOne();
+	$cntnewsy = $cnewsy['c'];
+
+	$cnewsyy = Yii::$app->db->createCommand("select count(id) as c  from news where `dt_pub` BETWEEN DATE_SUB('".$b_date."',  INTERVAL 1 YEAR) AND '".$e_date."' and active = 'Y'")->queryOne();
+	$cntnewsyy = $cnewsyy['c'];
+
+
+	$now = time();
+	$ndate = strtotime( $y."-01-01");
+	$datediff = $now - $ndate;
+    $daysp =  round($datediff / (60 * 60 * 24));
+
+	$edate = strtotime( $y."-12-31");
+	$datediff = $now - $edate;
+    $dayso =  -round($datediff / (60 * 60 * 24));
+
+	$newsinterpolite = round($cntnewsy*$dayso/$daysp);
+
+
+
+//	echo $cntnewsp;
 ?>
 <section class="content dark-mode">
 <div class="container-fluid">
@@ -80,9 +109,9 @@ echo 100-$out[0]*1;
 
 <div class="col-12 col-sm-6 col-md-3">
 <div class="info-box mb-3">
-<span class="info-box-icon bg-danger elevation-1"><i class="fas fa-thumbs-up"></i></span>
+<span class="info-box-icon bg-warning elevation-1"><i class="fas fa-users"></i></span>
 <div class="info-box-content">
-<span class="info-box-text">Запросов</span>
+<span class="info-box-text">Запросов в секунду</span>
 <span class="info-box-number">
 <?
 $str = "wget -q -O - http://localhost/nginx_status |grep 'Active connections:'";
@@ -101,7 +130,7 @@ $s = explode(':',$out[0]);
 <div class="clearfix hidden-md-up"></div>
 <div class="col-12 col-sm-6 col-md-3">
 <div class="info-box mb-3">
-<span class="info-box-icon bg-success elevation-1"><i class="fas fa-shopping-cart"></i></span>
+<span class="info-box-icon bg-success elevation-1"><i class="fas fa-thumbs-up"></i></span>
 <div class="info-box-content">
 <span class="info-box-text">Наибольшее число новостей</span>
 <span class="info-box-number"><?=$max?></span>
@@ -113,7 +142,7 @@ $s = explode(':',$out[0]);
 
 <div class="col-12 col-sm-6 col-md-3">
 <div class="info-box mb-3">
-<span class="info-box-icon bg-warning elevation-1"><i class="fas fa-users"></i></span>
+<span class="info-box-icon bg-danger elevation-1"><i class="fas fa-thumbs-down"></i></span>
 <div class="info-box-content">
 <span class="info-box-text">Минимум новостей</span>
 <span class="info-box-number"><?=$min?></span>
@@ -177,7 +206,7 @@ $s = explode(':',$out[0]);
 </div>
 
 <div class="progress-group">
-<span class="progress-text">усреднее число новостей</span>
+<span class="progress-text">среднее число новостей</span>
 <span class="float-right"><b><?=round($sum/count($cmd))?></b>/<?=$max?></span>
 <div class="progress progress-sm">
 <div class="progress-bar bg-success" style="width: <?=round($sum/count($cmd)*100/$max)?>%"></div>
@@ -196,6 +225,47 @@ $s = explode(':',$out[0]);
 
 </div>
 
+<div class="card-footer">
+<div class="row">
+<div class="col-sm-3 col-6">
+<div class="description-block border-right">
+<span class="description-percentage <?=$cntnews-$cntnewsp>0?'text-success':'text-danger'?>" title="От предыдущего месяца <?=$cntnewsp?>"><i class="fas <?=$cntnews-$cntnewsp>0?'fa-caret-up':'fa-caret-down'?>"></i><?=round(($cntnews-$cntnewsp)*100/$cntnewsp, 1)?>%</span>
+<h5 class="description-header"><?=$cntnews?></h5>
+<span class="description-text">Всего новостей за месяц</span>
+</div>
+
+</div>
+
+<div class="col-sm-3 col-6">
+<div class="description-block border-right">
+<span class="description-percentage <?=$cntnewsy-$cntnewsyy>0?'text-success':'text-danger'?>" title="До конца года <?=$cntnewsyy?>"><i class="fas <?=$cntnewsy-$cntnewsyy>0?'fa-caret-up':'fa-caret-down'?>"></i><?=round(($cntnewsy-$cntnewsyy)*100/$cntnewsyy, 1)?>%</span>
+<h5 class="description-header"><?=$cntnewsy?></h5>
+<span class="description-text">Новостей сначала года</span>
+</div>
+
+</div>
+
+<div class="col-sm-3 col-6">
+<div class="description-block border-right">
+<span class="description-percentage text-success"><i class="fas fa-caret-up"></i> 0%</span>
+<h5 class="description-header"><?=$cntnewsyy?></h5>
+<span class="description-text">За 365 дней</span>
+</div>
+
+</div>
+
+<div class="col-sm-3 col-6">
+<div class="description-block">
+<span class="description-percentage text-danger" title="От прошлого года"><i class="fas <?=($newsinterpolite+$cntnewsy)-$cntnewsyy>0?'text-success':'text-danger'?>"></i><i class="fas <?=($newsinterpolite+$cntnewsy)-$cntnewsyy>0?'fa-caret-up':'fa-caret-down'?>"></i><?=round((($newsinterpolite+$cntnewsy)-$cntnewsyy)*100/$cntnewsyy, 1)?>%</span>
+<h5 class="description-header"><?=$newsinterpolite+$cntnewsy?></h5>
+<span class="description-text">Будет новостей за этот год</span>
+</div>
+
+</div>
+</div>
+
+</div>
+
 </div>
 
 </div>