Commit 5d79178c authored by root's avatar root

Adding payment processor stats

parent 503a8f63
......@@ -684,6 +684,20 @@ CREATE TABLE IF NOT EXISTS `pingback_extension` (
-- --------------------------------------------------------
--
-- Table structure for table `pingback_payproc`
--
DROP TABLE IF EXISTS `pingback_payproc`;
CREATE TABLE IF NOT EXISTS `pingback_payproc` (
`site_id` int(11) unsigned DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
KEY `site_id` (`site_id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
---
-- Table structure for table `sourceforge_download`
--
......
......@@ -91,7 +91,7 @@ $queries[] = array(
FROM pingback_site
WHERE is_active = 1
GROUP BY civi_version, php_version
ORDER BY LEFT(civi_version, 1) DESC, CAST(MID(civi_version, 3) AS SIGNED INTEGER) DESC, php_version DESC
ORDER BY civi_version DESC, php_version DESC
",
);
$queries[] = array(
......@@ -145,6 +145,25 @@ $queries[] = array(
LIMIT 50 -- privacy: only report on top (ie. public) extensions
",
);
$queries[] = array(
'file' => 'payproc-stats.json',
'archive' => 'monthly',
'query' => "
SELECT COUNT(DISTINCT(`name`)) AS num_payprocs, COUNT(*) AS num_installs
FROM pingback_payproc
",
);
$queries[] = array(
'file' => 'payproc-detail.json',
'archive' => 'weekly, monthly',
'query' => "
SELECT name, COUNT(*) as num_sites
FROM pingback_payproc
GROUP BY name
ORDER BY num_sites DESC
LIMIT 50 -- privacy: only report on top (ie. public) extensions
",
);
$queries[] = array(
'file' => 'contacts-range.json',
'archive' => 'monthly',
......
......@@ -105,3 +105,21 @@ $result = $dbh->query("SELECT COUNT(DISTINCT `name`) FROM pingback_extension")->
echo "Unique active extensions: $result[0]" . PHP_EOL;
$result = $dbh->query("SELECT COUNT(*) FROM pingback_extension")->fetch();
echo "Total enabled extensions: $result[0]" . PHP_EOL;
// Now calculate the payment processor stats
$dbh->query("TRUNCATE pingback_payproc");
$query = "
SELECT r.id, r.PPTypes
FROM pingback_site s
LEFT JOIN " . DBPING . ".stats r ON r.id = s.last_ping_id
WHERE s.is_active = 1";
$sth = $dbh->prepare("INSERT INTO pingback_payproc (`site_id`, `name`) VALUES (:site_id, :name)");
foreach ($dbh->query($query) as $row) {
foreach (explode(',', $row[1]) as $payproc) {
if ($row[0] && $payproc) {
$sth->execute(array(':site_id' => $row[0], ':name' => $payproc));
}
}
}
$result = $dbh->query("SELECT COUNT(DISTINCT `name`) FROM pingback_payproc")->fetch();
echo "Unique active payment processors: $result[0]" . PHP_EOL;
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