Commit 7d60e34d authored by cividesk's avatar cividesk

Add stats by extension version in extension stats...

Add stats by extension version in extension stats (extensions/extensions-directory#14)
parent 3a757d23
...@@ -12,7 +12,7 @@ foreach ($result as $row) { ...@@ -12,7 +12,7 @@ foreach ($result as $row) {
", ",
'subqueries' => array( 'subqueries' => array(
'installs_by_version' => " 'installs_by_version' => "
SELECT LEFT(version, LOCATE('.', version, 4)-1) AS short_version, COUNT(*) AS num_sites SELECT LEFT(version, LOCATE('.', s.version, 4)-1) AS short_version, COUNT(*) AS num_sites
FROM pingback_extension e FROM pingback_extension e
LEFT JOIN pingback_site s ON s.id = e.site_id LEFT JOIN pingback_site s ON s.id = e.site_id
WHERE `name` = '$row[fq_name]' WHERE `name` = '$row[fq_name]'
...@@ -26,6 +26,14 @@ foreach ($result as $row) { ...@@ -26,6 +26,14 @@ foreach ($result as $row) {
WHERE `name` = '$row[fq_name]' WHERE `name` = '$row[fq_name]'
GROUP BY lang GROUP BY lang
ORDER BY num_sites DESC ORDER BY num_sites DESC
",
'installs_by_extension_version' => "
SELECT e.version, COUNT(*) AS num_sites
FROM pingback_extension e
LEFT JOIN pingback_site s ON s.id = e.site_id
WHERE `name` = '$row[fq_name]'
GROUP BY e.version
ORDER BY num_sites DESC
" "
) )
); );
......
...@@ -672,10 +672,11 @@ CREATE TABLE IF NOT EXISTS `pingback_cohort` ( ...@@ -672,10 +672,11 @@ CREATE TABLE IF NOT EXISTS `pingback_cohort` (
DROP TABLE IF EXISTS `pingback_extension`; DROP TABLE IF EXISTS `pingback_extension`;
CREATE TABLE IF NOT EXISTS `pingback_extension` ( CREATE TABLE IF NOT EXISTS `pingback_extension` (
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`site_id` int(11) unsigned DEFAULT NULL, `site_id` int(11) unsigned DEFAULT NULL,
KEY `name` (`name`), `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
KEY `site_id` (`site_id`) `version` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
KEY `site_id` (`site_id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- -------------------------------------------------------- -- --------------------------------------------------------
......
...@@ -30,11 +30,13 @@ foreach ($queries as $query) { ...@@ -30,11 +30,13 @@ foreach ($queries as $query) {
if (isset($query['subqueries'])) { if (isset($query['subqueries'])) {
foreach ($query['subqueries'] as $attr => $subquery) { foreach ($query['subqueries'] as $attr => $subquery) {
$row[$attr] = array(); $row[$attr] = array();
foreach ($dbh->query($subquery, PDO::FETCH_ASSOC) as $subrow) { if ($subresults = $dbh->query($subquery, PDO::FETCH_ASSOC)) {
foreach ($subresults as $subrow) {
$row[$attr][] = $subrow; $row[$attr][] = $subrow;
} }
} }
} }
}
$out .= json_encode($row) . ','; $out .= json_encode($row) . ',';
$count ++; $count ++;
} }
......
...@@ -91,8 +91,8 @@ VALUES ('$cohort', '$month', ( ...@@ -91,8 +91,8 @@ VALUES ('$cohort', '$month', (
$dbh->query("TRUNCATE pingback_extension"); $dbh->query("TRUNCATE pingback_extension");
$query = " $query = "
INSERT INTO pingback_extension INSERT INTO pingback_extension
(`name`, `site_id`) (`name`, `site_id`, `version`)
SELECT e.name, s.id SELECT e.name, s.id, e.version
FROM pingback_site s FROM pingback_site s
LEFT JOIN " . DBPING . ".extensions e ON e.stat_id = s.last_ping_id AND e.enabled = 1 LEFT JOIN " . DBPING . ".extensions e ON e.stat_id = s.last_ping_id AND e.enabled = 1
WHERE s.is_active = 1 WHERE s.is_active = 1
......
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