Commit 8d593409 by san58

Доработал статистику

1 parent ef9ee814
...@@ -67,7 +67,7 @@ class SiteController extends Controller ...@@ -67,7 +67,7 @@ class SiteController extends Controller
{ {
//var_dump(Yii::$app->user->isGuest); //var_dump(Yii::$app->user->isGuest);
//var_dump(Yii::$app->user->identity); //var_dump(Yii::$app->user->identity);
$statistics = ['csv_date' => '', 'whois_status'=>[], 'itx_status'=>[]]; $statistics = ['csv_date' => '', 'whois_status'=>[], 'itx_status'=>[], 'domain_count'=>0, 'domain_filtred'=>0, 'domain_whois'=>0, 'domain_tix'=>0];
$statistics['whois_status'] = (new yii\db\Query()) $statistics['whois_status'] = (new yii\db\Query())
->select(['COUNT(*) AS cnt', 'wis_status', 'status']) ->select(['COUNT(*) AS cnt', 'wis_status', 'status'])
->from('{{%host}}') ->from('{{%host}}')
...@@ -80,10 +80,59 @@ class SiteController extends Controller ...@@ -80,10 +80,59 @@ class SiteController extends Controller
->groupBy(['tix_status', 'status']) ->groupBy(['tix_status', 'status'])
->all(); ->all();
$statistics['itx_status_pure'] = (new yii\db\Query())
->select(['COUNT(*) AS cnt', 'tix_status', 'status'])
->from('{{%host}}')
->where(
[
'wis_status'=>Host::STATUS_WIS_FREE
]
)
->groupBy(['tix_status', 'status'])
->all();
$csv = Host::find()->select(['csv_date'])->orderBy('csv_date ASC')->one(); $csv = Host::find()->select(['csv_date'])->orderBy('csv_date ASC')->one();
if ($csv) if ($csv)
$statistics['csv_date'] = $csv['csv_date']; $statistics['csv_date'] = $csv['csv_date'];
$cnt_domain = (new yii\db\Query())
->select(['COUNT(`id`) AS cnt'])
->from('{{%host}}')
->one();
if ($cnt_domain && isset($cnt_domain['cnt']))
$statistics['domain_count'] = $cnt_domain['cnt'];
unset($cnt_domain);
$cnt_domain = (new yii\db\Query())
->select(['COUNT(`id`) AS cnt'])
->from('{{%host}}')
->where(['status'=>Host::STATUS_ON])
->one();
if ($cnt_domain && isset($cnt_domain['cnt']))
$statistics['domain_filtred'] = $cnt_domain['cnt'];
unset($cnt_domain);
$cnt_domain_wis = (new yii\db\Query())
->select(['COUNT(`id`) AS cnt'])
->from('{{%host}}')
->where('wis_status<>:wis_status', array(':wis_status'=>Host::STATUS_WIS_NONE ))
->one();
if ($cnt_domain_wis && isset($cnt_domain_wis['cnt']))
$statistics['domain_whois'] = $cnt_domain_wis['cnt'];
unset($cnt_domain_wis);
$cnt_domain_wis = (new yii\db\Query())
->select(['COUNT(`id`) AS cnt'])
->from('{{%host}}')
->where(['tix_status'=>Host::STATUS_TIX_CHECK])
->one();
if ($cnt_domain_wis && isset($cnt_domain_wis['cnt']))
$statistics['domain_tix'] = $cnt_domain_wis['cnt'];
unset($cnt_domain_wis);
return $this->render('index', ['statistics'=>$statistics]); return $this->render('index', ['statistics'=>$statistics]);
} }
......
...@@ -23,7 +23,7 @@ class m191025_123812_user extends Migration ...@@ -23,7 +23,7 @@ class m191025_123812_user extends Migration
$this->insert('{{%user}}', [ $this->insert('{{%user}}', [
'login' => 'admin', 'login' => 'admin',
'pass' =>Yii::$app->getSecurity()->generatePasswordHash('qwerty'), 'pass' =>Yii::$app->getSecurity()->generatePasswordHash('qwerty'),
'name' => 'Админ', 'name' => 'Admin',
'auth_key' => md5(time()), 'auth_key' => md5(time()),
'data_created' => date("Y-m-d H:i:s") 'data_created' => date("Y-m-d H:i:s")
]); ]);
......
...@@ -13,9 +13,27 @@ echo '</pre>'; ...@@ -13,9 +13,27 @@ echo '</pre>';
?> ?>
<h2>Statistics</h2> <h2>Statistics</h2>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Current datatime</dt>
<dd><?php echo date('Y.m.d H:i:s'); ?></dd>
<dt>Datatime of CSV-file </dt> <dt>Datatime of CSV-file </dt>
<dd><?php echo $statistics['csv_date']; ?></dd> <dd><?php echo $statistics['csv_date']; ?></dd>
</dl> </dl>
<h3>Domain count</h3>
<dl class="dl-horizontal">
<dt>All</dt>
<dd><?php echo $statistics['domain_count']; ?></dd>
<dt>Filtred</dt>
<dd><?php echo $statistics['domain_filtred']; ?></dd>
<dt>Whois checked</dt>
<dd><?php echo $statistics['domain_whois']; ?></dd>
<dt>TIX checked</dt>
<dd><?php echo $statistics['domain_tix']; ?></dd>
</dl>
<?php <?php
$domain_count = [ $domain_count = [
...@@ -27,7 +45,7 @@ foreach($statistics['whois_status'] as $st_value) ...@@ -27,7 +45,7 @@ foreach($statistics['whois_status'] as $st_value)
$domain_count[$st_value['wis_status']][(int)$st_value['status']] = (int)$st_value['cnt']; $domain_count[$st_value['wis_status']][(int)$st_value['status']] = (int)$st_value['cnt'];
unset($st_value); unset($st_value);
?> ?>
<h2>WHO IS</h2> <h3>WHO IS</h3>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered table-hover table-striped">
<tr> <tr>
...@@ -55,7 +73,7 @@ unset($st_value); ...@@ -55,7 +73,7 @@ unset($st_value);
<td><?php echo $domain_count[Host::STATUS_WIS_FREE][0]+$domain_count[Host::STATUS_WIS_FREE][1]; ?></td> <td><?php echo $domain_count[Host::STATUS_WIS_FREE][0]+$domain_count[Host::STATUS_WIS_FREE][1]; ?></td>
</tr> </tr>
<tr> <tr>
<th class="text-right">All count</th> <th class="text-right">Total count</th>
<td><?php echo $domain_count[Host::STATUS_WIS_NONE][0]+$domain_count[Host::STATUS_WIS_BUSY][0]+$domain_count[Host::STATUS_WIS_FREE][0]; ?></td> <td><?php echo $domain_count[Host::STATUS_WIS_NONE][0]+$domain_count[Host::STATUS_WIS_BUSY][0]+$domain_count[Host::STATUS_WIS_FREE][0]; ?></td>
<td><?php echo $domain_count[Host::STATUS_WIS_NONE][1]+$domain_count[Host::STATUS_WIS_BUSY][1]+$domain_count[Host::STATUS_WIS_FREE][1]; ?></td> <td><?php echo $domain_count[Host::STATUS_WIS_NONE][1]+$domain_count[Host::STATUS_WIS_BUSY][1]+$domain_count[Host::STATUS_WIS_FREE][1]; ?></td>
<td><?php <td><?php
...@@ -78,7 +96,7 @@ foreach($statistics['itx_status'] as $st_value) ...@@ -78,7 +96,7 @@ foreach($statistics['itx_status'] as $st_value)
$domain_count[$st_value['tix_status']][(int)$st_value['status']] = (int)$st_value['cnt']; $domain_count[$st_value['tix_status']][(int)$st_value['status']] = (int)$st_value['cnt'];
unset($st_value); unset($st_value);
?> ?>
<h2>TIX</h2> <h3>TIX</h3>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered table-hover table-striped">
<tr> <tr>
...@@ -100,7 +118,7 @@ unset($st_value); ...@@ -100,7 +118,7 @@ unset($st_value);
<td><?php echo $domain_count[Host::STATUS_TIX_CHECK][0]+$domain_count[Host::STATUS_TIX_CHECK][1]; ?></td> <td><?php echo $domain_count[Host::STATUS_TIX_CHECK][0]+$domain_count[Host::STATUS_TIX_CHECK][1]; ?></td>
</tr> </tr>
<tr> <tr>
<th class="text-right">All count</th> <th class="text-right">Total count</th>
<td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][0]+$domain_count[Host::STATUS_TIX_CHECK][0]; ?></td> <td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][0]+$domain_count[Host::STATUS_TIX_CHECK][0]; ?></td>
<td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][1]+$domain_count[Host::STATUS_TIX_CHECK][1]; ?></td> <td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][1]+$domain_count[Host::STATUS_TIX_CHECK][1]; ?></td>
<td><?php <td><?php
...@@ -109,4 +127,49 @@ unset($st_value); ...@@ -109,4 +127,49 @@ unset($st_value);
?></td> ?></td>
</tr> </tr>
</table> </table>
</div>
<?php
$domain_count = [
Host::STATUS_TIX_UNCHECK=>[0,0],
Host::STATUS_TIX_CHECK=>[0,0],
];
foreach($statistics['itx_status_pure'] as $st_value)
$domain_count[$st_value['tix_status']][(int)$st_value['status']] = (int)$st_value['cnt'];
unset($st_value);
?>
<h3>TIX pure</h3>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped">
<tr>
<th width="40%">Status TIX checked</th>
<th width="20%">Count of Disabled</th>
<th width="20%">Count of Enabled</th>
<th width="20%">Count of All</th>
</tr>
<tr>
<td>No checked</td>
<td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][0]; ?></td>
<td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][1]; ?></td>
<td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][0]+$domain_count[Host::STATUS_TIX_UNCHECK][1]; ?></td>
</tr>
<tr>
<td>Checked</td>
<td><?php echo $domain_count[Host::STATUS_TIX_CHECK][0]; ?></td>
<td><?php echo $domain_count[Host::STATUS_TIX_CHECK][1]; ?></td>
<td><?php echo $domain_count[Host::STATUS_TIX_CHECK][0]+$domain_count[Host::STATUS_TIX_CHECK][1]; ?></td>
</tr>
<tr>
<th class="text-right">Total count</th>
<td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][0]+$domain_count[Host::STATUS_TIX_CHECK][0]; ?></td>
<td><?php echo $domain_count[Host::STATUS_TIX_UNCHECK][1]+$domain_count[Host::STATUS_TIX_CHECK][1]; ?></td>
<td><?php
echo $domain_count[Host::STATUS_TIX_UNCHECK][0]+$domain_count[Host::STATUS_TIX_UNCHECK][1]+
$domain_count[Host::STATUS_TIX_CHECK][0]+$domain_count[Host::STATUS_TIX_CHECK][1];
?></td>
</tr>
</table>
</div> </div>
\ No newline at end of file \ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!