Commit 6678a984 authored by cividesk's avatar cividesk

Changed definition of an active site, added active sites stats

parent 2a7e1b39
......@@ -8,14 +8,16 @@ $queries[] = array(
ORDER BY `month` ASC
",
);
// If the dashboard service can interpret this ...
$queries[] = array(
'file' => 'active-sites-stats.json',
'file' => 'active-sites.json',
'query' => "
SELECT COUNT(*) AS active_sites, SUM(Contact) AS total_contacts, SUM(Contribution) AS total_contributions, SUM(Participant) AS total_participants
SELECT version, lang, uf, MySQL, PHP, Contact, Contribution, Participant
FROM pingback_site
WHERE is_active = 1
",
);
// Otherwise let's pre-digest the information
$queries[] = array(
'file' => 'active-sites-version.json',
'query' => "
......@@ -26,6 +28,34 @@ $queries[] = array(
ORDER BY num_sites DESC
",
);
$queries[] = array(
'file' => 'active-sites-lang.json',
'query' => "
SELECT lang, COUNT(*) AS num_sites
FROM pingback_site
WHERE is_active = 1
GROUP BY lang
ORDER BY num_sites DESC
",
);
$queries[] = array(
'file' => 'active-sites-uf.json',
'query' => "
SELECT uf, COUNT(*) AS num_sites
FROM pingback_site
WHERE is_active = 1
GROUP BY uf
ORDER BY num_sites DESC
",
);
$queries[] = array(
'file' => 'active-sites-stats.json',
'query' => "
SELECT COUNT(*) AS active_sites, SUM(Contact) AS total_contacts, SUM(Contribution) AS total_contributions, SUM(Participant) AS total_participants
FROM pingback_site
WHERE is_active = 1
",
);
$queries[] = array(
'file' => 'extensions-detail.json',
'query' => "
......
......@@ -38,8 +38,10 @@ echo "Total sites: $result[0]" . PHP_EOL;
// Calculate the active sites flag
$dbh->query("
UPDATE pingback_site
SET is_active = last_timestamp > (NOW() - INTERVAL 100 DAY)
AND Contact NOT IN ( 1, 2, 102, 202 )
SET is_active = (
last_timestamp > (NOW() - INTERVAL 100 DAY)
AND Contact > 10 AND Contact NOT IN (201, 202, 203, 204)
)
");
$result = $dbh->query("SELECT COUNT(*) FROM pingback_site WHERE is_active = 1;")->fetch();
echo "Total active sites: $result[0]" . PHP_EOL;
......@@ -51,7 +53,7 @@ INSERT INTO pingback_extension
(`name`, `num_sites`)
SELECT e.name, COUNT(*) AS num_sites
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
AND LENGTH(e.name) > 2 AND e.name NOT LIKE 'org.civicrm.component%'
GROUP BY e.name
......
......@@ -44,6 +44,20 @@ SELECT COUNT(*) AS active_sites, SUM(contacts) AS total_contacts, SUM(contributi
-- Number of contacts per active site
SELECT COUNT(*) as num_sites, Contact
FROM pingback_site
WHERE is_active = 1
WHERE last_timestamp > (NOW() - INTERVAL 100 DAY)
GROUP BY Contact
ORDER BY num_sites DESC
\ No newline at end of file
ORDER BY num_sites DESC
LIMIT 25;
SELECT COUNT(*) as num_sites, SUM(Contact), SUM(Participant), SUM(Contribution)
FROM pingback_site
WHERE last_timestamp > (NOW() - INTERVAL 50 DAY)
AND Contact > 10 AND Contact NOT IN (201, 202, 203, 204)
AND num_pings > 4
AND last_timestamp > (first_timestamp + INTERVAL 100 DAY)
SELECT COUNT(*) as num_sites, SUM(Contact)
FROM pingback_site
WHERE last_timestamp > (NOW() - INTERVAL 100 DAY)
AND Contact > 10 AND Contact NOT IN (201, 202, 203, 204)
AND last_timestamp > (first_timestamp + INTERVAL 100 DAY)
\ No newline at end of file
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