Commit 722bc8d8 authored by cividesk's avatar cividesk

Adds MySQL DB and PHP statistics

parent bf278583
......@@ -181,6 +181,8 @@ CREATE TABLE IF NOT EXISTS `pingback_site` (
`lang` text COLLATE ascii_bin,
`uf` text COLLATE ascii_bin,
`ufv` text COLLATE ascii_bin,
`geoip_country` varchar(50) COLLATE ascii_bin DEFAULT NULL,
`DB` char(2) COLLATE ascii_bin DEFAULT NULL,
`MySQL` text COLLATE ascii_bin,
`PHP` text COLLATE ascii_bin,
`first_ping_id` bigint(20) unsigned NOT NULL,
......@@ -197,7 +199,8 @@ CREATE TABLE IF NOT EXISTS `pingback_site` (
KEY `first_timestamp` (`first_timestamp`),
KEY `last_ping_id` (`last_ping_id`),
KEY `last_timestamp` (`last_timestamp`),
KEY `is_active` (`is_active`)
KEY `is_active` (`is_active`),
KEY `DB` (`DB`)
) ENGINE=MyISAM DEFAULT CHARSET=ascii COLLATE=ascii_bin AUTO_INCREMENT=120191 ;
-- --------------------------------------------------------
......
......@@ -11,7 +11,7 @@ $queries[] = array(
$queries[] = array(
'file' => 'active-sites-version.json',
'query' => "
SELECT CONCAT(LEFT(version, 3), '.x') AS short_version, COUNT(*) AS num_sites
SELECT CONCAT(LEFT(version, LOCATE('.', version, 4)), 'x') AS short_version, COUNT(*) AS num_sites
FROM pingback_site
WHERE is_active = 1
GROUP BY short_version
......@@ -53,6 +53,28 @@ $queries[] = array(
ORDER BY num_sites DESC
",
);
$queries[] = array(
'file' => 'active-sites-server-php.json',
'query' => "
SELECT CASE CONCAT(LEFT(PHP, LOCATE('.', PHP, 4) - 1) AS short_version, COUNT(*) AS num_sites
FROM pingback_site
WHERE is_active = 1
GROUP BY short_version
ORDER BY num_sites DESC
LIMIT 10 -- privacy: we do not need more for the graph
",
);
$queries[] = array(
'file' => 'active-sites-server-mysql.json',
'query' => "
SELECT CONCAT(LEFT(MySQL, LOCATE('.', MySQL, 4) - 1), ' (', DB, ')') AS short_version, COUNT(*) AS num_sites
FROM pingback_site
WHERE is_active = 1
GROUP BY short_version
ORDER BY num_sites DESC
LIMIT 10 -- privacy: we do not need more for the graph
",
);
$queries[] = array(
'file' => 'active-sites-stats.json',
'query' => "
......
......@@ -38,6 +38,16 @@ $dbh->query($query);
$result = $dbh->query("SELECT COUNT(*) FROM pingback_site;")->fetch();
echo "Total sites: $result[0]" . PHP_EOL;
// Set the DB flavor - MySQL, MariaDB, Percona
$query = "
UPDATE pingback_site
SET DB = CASE
WHEN MySQL LIKE '%percona%' THEN 'Pr'
WHEN MySQL LIKE '%MariaDB%' THEN 'Ma'
ELSE 'My' END
WHERE DB IS NULL";
$dbh->query($query);
// Calculate the active sites flag
$dbh->query("
UPDATE pingback_site
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment