Commit 4b1456ea authored by cividesk's avatar cividesk

Collect more details for extension stats

parent 26ee2a66
...@@ -616,19 +616,6 @@ CREATE TABLE IF NOT EXISTS `jira_version` ( ...@@ -616,19 +616,6 @@ CREATE TABLE IF NOT EXISTS `jira_version` (
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Table structure for table `pingback_extension`
--
DROP TABLE IF EXISTS `pingback_extension`;
CREATE TABLE IF NOT EXISTS `pingback_extension` (
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`num_sites` int(11) unsigned DEFAULT NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
-- --
-- Table structure for table `pingback_site` -- Table structure for table `pingback_site`
-- --
...@@ -678,6 +665,20 @@ CREATE TABLE IF NOT EXISTS `pingback_cohort` ( ...@@ -678,6 +665,20 @@ CREATE TABLE IF NOT EXISTS `pingback_cohort` (
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Table structure for table `pingback_extension`
--
DROP TABLE IF 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,
KEY `name` (`name`),
KEY `site_id` (`site_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
-- --
-- Table structure for table `sourceforge_download` -- Table structure for table `sourceforge_download`
-- --
...@@ -729,6 +730,22 @@ CREATE TABLE IF NOT EXISTS `stackexchange_users` ( ...@@ -729,6 +730,22 @@ CREATE TABLE IF NOT EXISTS `stackexchange_users` (
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Table structure for table `extensions_dir`
--
DROP TABLE IF EXISTS `extensions_dir`;
CREATE TABLE IF NOT EXISTS `extensions_dir` (
`nid` INT(10) NOT NULL,
`title` varchar(255) CHARACTER SET ascii NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`fq_name` varchar(255) CHARACTER SET ascii NOT NULL,
`git_url` varchar(255) CHARACTER SET ascii NOT NULL,
PRIMARY KEY (`nid`),
KEY `fq_name` (`fq_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
...@@ -117,7 +117,7 @@ $queries[] = array( ...@@ -117,7 +117,7 @@ $queries[] = array(
'file' => 'extensions-stats.json', 'file' => 'extensions-stats.json',
'archive' => 'monthly', 'archive' => 'monthly',
'query' => " 'query' => "
SELECT COUNT(*) AS num_extensions, SUM(num_sites) AS num_installs SELECT COUNT(UNIQUE `name`) AS num_extensions, COUNT(*) AS num_installs
FROM pingback_extension FROM pingback_extension
", ",
); );
...@@ -125,7 +125,9 @@ $queries[] = array( ...@@ -125,7 +125,9 @@ $queries[] = array(
'file' => 'extensions-detail.json', 'file' => 'extensions-detail.json',
'archive' => 'weekly, monthly', 'archive' => 'weekly, monthly',
'query' => " 'query' => "
SELECT * FROM pingback_extension SELECT name, COUNT(*) as num_sites
FROM pingback_extension
GROUP BY name
ORDER BY num_sites DESC ORDER BY num_sites DESC
LIMIT 50 -- privacy: only report on top (ie. public) extensions LIMIT 50 -- privacy: only report on top (ie. public) extensions
", ",
......
...@@ -91,13 +91,12 @@ VALUES ('$cohort', '$month', ( ...@@ -91,13 +91,12 @@ VALUES ('$cohort', '$month', (
$dbh->query("TRUNCATE pingback_extension"); $dbh->query("TRUNCATE pingback_extension");
$query = " $query = "
INSERT INTO pingback_extension INSERT INTO pingback_extension
(`name`, `num_sites`) (`name`, `site_id`)
SELECT e.name, COUNT(*) AS num_sites SELECT e.name, s.id
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
AND LENGTH(e.name) > 2 AND e.name NOT LIKE 'org.civicrm.component%' AND LENGTH(e.name) > 2 AND e.name NOT LIKE 'org.civicrm.component%'
GROUP BY e.name
"; ";
$dbh->query($query); $dbh->query($query);
$result = $dbh->query("SELECT COUNT(*) FROM pingback_extension")->fetch(); $result = $dbh->query("SELECT COUNT(*) FROM pingback_extension")->fetch();
......
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