예제 #1
0
파일: index.php 프로젝트: Devdits/pinboard
<?php

use Doctrine\DBAL\Cache\QueryCacheProfile;
use Pinboard\Utils\IDNaConvert;
use Pinboard\Utils\Utils;
$index = $app['controllers_factory'];
$index->get('/', function () use($app) {
    $result = array();
    $params = array('created_at' => date('Y-m-d H:00:00', strtotime('-1 day')));
    $hostsRegexp = Utils::getUserAccessHostsRegexp($app);
    $hostsWhere = '';
    if ($hostsRegexp != '.*') {
        $hostsRegexp = is_array($hostsRegexp) ? $hostsRegexp : array($hostsRegexp);
        $hostsWhere = " AND (a.server_name REGEXP '" . implode("' OR a.server_name REGEXP '", $hostsRegexp) . "')";
    }
    $sql = '
        SELECT
            a.server_name,
            sum(a.req_count) as req_count,
            avg(a.req_per_sec) as req_per_sec,
            (
                SELECT
                    count(*)
                FROM
                    ipm_status_details b
                WHERE
                    a.server_name = b.server_name AND b.created_at > :created_at
            )
            as error_count
        FROM
            ipm_report_by_hostname_and_server a