Commit 8b5af9c1 authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by root
Browse files

Add a JSONDIR setting, tweak the json format, display extension title instead of ext key.

parent 6870bac4
......@@ -24,5 +24,8 @@ const DBFORUM = 'civicrm_forum';
// Date of the start of the project (from JIRA)
const DATESTART = '2004-12-07 06:13:00';
// Where to write json files
const JSONDIR = '/var/www/stats.civicrm.org/public/json';
// GitHub credentials
define('GITHUB_TOKEN', '<token>');
<?php
require_once('config.php');
$directory = __DIR__ . '/json';
$directory = JSONDIR;
foreach (array($directory, "$directory/ext") as $dir) {
if (!file_exists($dir)) {
mkdir($dir);
......@@ -23,7 +23,7 @@ foreach ($files as $file) {
// Run the queries and generate target file
foreach ($queries as $query) {
echo "Creating $query[file] ...";
echo "Creating $directory/{$query['file']} ...";
$count = 0;
$out = '[';
foreach ($dbh->query($query['query'], PDO::FETCH_ASSOC) as $row) {
......@@ -37,7 +37,10 @@ foreach ($queries as $query) {
}
}
}
$out .= json_encode($row) . ',';
$t = json_encode($row);
if ($t) {
$out .= json_encode($row) . ',';
}
$count ++;
}
......
......@@ -138,11 +138,11 @@ $queries[] = array(
'file' => 'extensions-detail.json',
'archive' => 'weekly, monthly',
'query' => "
SELECT substring_index(name, '.', -1) as name, COUNT(*) as num_sites
FROM pingback_extension
GROUP BY name
SELECT pe.name, ed.title as title, COUNT(*) as num_sites
FROM pingback_extension pe
INNER JOIN extensions_dir ed ON (pe.name = ed.fq_name)
GROUP BY ed.title
ORDER BY num_sites DESC
LIMIT 50 -- privacy: only report on top (ie. public) extensions
",
);
$queries[] = array(
......
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