Commit aa93b42f authored by cividesk's avatar cividesk

Corrections due to rebuild of Biryani.

parent fea715cb
#! /bin/bash #! /bin/bash
DEST=/var/www/stats.civicrm.org/public/ DEST=/var/www/stats.civicrm.org/public
ARCH=/var/www/stats.civicrm.org/archive
# For the log file # For the log file
echo "--- CiviCRM Statistics run on `date` ---" echo "--- CiviCRM Statistics run on `date` ---"
...@@ -19,13 +20,13 @@ done ...@@ -19,13 +20,13 @@ done
# Regenerate statistics and push to destination # Regenerate statistics and push to destination
php generate.php php generate.php
php historical.php php historical.php
rsync -a json $DEST rsync -a json/ $DEST/
# create .htaccess to allow access from anywhere (cf. CORS for $.getJSON) # create .htaccess to allow access from anywhere (cf. CORS for $.getJSON)
echo 'Header add Access-Control-Allow-Origin "*"' > $DEST/.htaccess echo 'Header add Access-Control-Allow-Origin "*"' > $DEST/.htaccess
# and also archive (will someday be useful one way or another ...) # and also archive (will someday be useful one way or another ...)
cp -R json /var/www/stats.civicrm.org/archive/`date +%F` cp -R json $ARCH/ `date +%F`
# For the log file # For the log file
echo --- Done --- echo --- Done ---
echo echo
\ No newline at end of file
...@@ -35,4 +35,4 @@ foreach ($api->values() as $row) { ...@@ -35,4 +35,4 @@ foreach ($api->values() as $row) {
echo $errorInfo[2] . PHP_EOL; echo $errorInfo[2] . PHP_EOL;
} }
} }
echo "$count CiviCRM-native extensions found in the Extensions Directory." . PHP_EOL; echo "$count CiviCRM-native extensions found in the Extensions Directory." . PHP_EOL;
\ No newline at end of file
<?php <?php
require_once('config.php'); require_once('config.php');
$directory = __DIR__ . '/json'; $directory = __DIR__ . '/json';
foreach (array($directory, "$directory/ext") as $dir) {
if (!file_exists($dir)) {
mkdir($dir);
}
}
// Initialize database // Initialize database
$dbh = new PDO('mysql:dbname='.DBNAME.';host='.DBHOST, DBUSER, DBPASS); $dbh = new PDO('mysql:dbname='.DBNAME.';host='.DBHOST, DBUSER, DBPASS);
// Remove the ONLY_FULL_GROUP_BY flag from SQL mode (MySQL 5.7.5 onwards)
// cf. https://stackoverflow.com/questions/37951742/1055-expression-of-select-list-is-not-in-group-by-clause-and-contains-nonaggr
$dbh->query("SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))");
// Initialize the queries array from each subdirectories' include file // Initialize the queries array from each subdirectories' include file
$queries = array(); $queries = array();
$files = glob_recursive('generate.inc.php'); $files = glob_recursive('generate.inc.php');
...@@ -12,13 +21,6 @@ foreach ($files as $file) { ...@@ -12,13 +21,6 @@ foreach ($files as $file) {
require_once($file); require_once($file);
} }
// Create target directories if non existent
foreach (array($directory, "$directory/ext") as $dir) {
if (!file_exists($dir)) {
mkdir($dir);
}
}
// Run the queries and generate target file // Run the queries and generate target file
foreach ($queries as $query) { foreach ($queries as $query) {
echo "Creating $query[file] ..."; echo "Creating $query[file] ...";
...@@ -47,4 +49,4 @@ function glob_recursive($pattern, $flags = 0) { ...@@ -47,4 +49,4 @@ function glob_recursive($pattern, $flags = 0) {
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir)
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
return $files; return $files;
} }
\ No newline at end of file
...@@ -48,10 +48,10 @@ foreach($repos as $repo) { ...@@ -48,10 +48,10 @@ foreach($repos as $repo) {
':repository' => $repo, ':repository' => $repo,
':hash' => $commit->getSha(), ':hash' => $commit->getSha(),
':author_login' => ($commit->getAuthor() ? $commit->getAuthor()->getLogin() : ''), ':author_login' => ($commit->getAuthor() ? $commit->getAuthor()->getLogin() : ''),
':author_date' => date('Y-m-d H:i:s', strtotime($commit->getCommit()->getAuthor()->getDate())), ':author_date' => str_replace(array('T','Z'), ' ', $commit->getCommit()->getAuthor()->getDate()),
':committer_login' => ($commit->getCommitter() ? $commit->getCommitter()->getLogin() : ''), ':committer_login' => ($commit->getCommitter() ? $commit->getCommitter()->getLogin() : ''),
':committer_date' => date('Y-m-d H:i:s', strtotime($commit->getCommit()->getCommitter()->getDate())), ':committer_date' => str_replace(array('T','Z'), ' ', $commit->getCommit()->getCommitter()->getDate()),
':message' => substr($commit->getCommit()->getMessage(), 0, 1000), ':message' => $commit->getCommit()->getMessage(),
); );
if ($stm_c->execute($params)) { if ($stm_c->execute($params)) {
$new_commits++; $new_commits++;
...@@ -108,4 +108,4 @@ $query = " ...@@ -108,4 +108,4 @@ $query = "
WHERE first_commit IS NULL; WHERE first_commit IS NULL;
"; ";
$dbh->query($query); $dbh->query($query);
echo " $updated updates, $skipped in error." . PHP_EOL; echo " $updated updates, $skipped in error." . PHP_EOL;
\ No newline at end of file
<?php <?php
$historical = __DIR__ . '/json/historical'; $historical = __DIR__ . '/json/historical';
if (!is_dir($historical)) {
mkdir($historical);
}
chdir(__DIR__ . '/../archive/'); chdir(__DIR__ . '/../archive/');
$reports = array( $reports = array(
...@@ -28,4 +31,4 @@ foreach($reports as $file => $params) { ...@@ -28,4 +31,4 @@ foreach($reports as $file => $params) {
$dir = date('Y-m-d', strtotime("$dir + $params[increment]")); $dir = date('Y-m-d', strtotime("$dir + $params[increment]"));
} }
file_put_contents("$historical/$file", json_encode($report)); file_put_contents("$historical/$file", json_encode($report));
} }
\ No newline at end of file
...@@ -40,7 +40,10 @@ foreach ($projects as $project) { ...@@ -40,7 +40,10 @@ foreach ($projects as $project) {
$count = 0; $count = 0;
foreach ($walker as $k => $issue) { foreach ($walker as $k => $issue) {
// Clean-up if we already had this issue in the database // Clean-up if we already had this issue in the database
$stm_id->execute(array(':issue' => $issue->getKey())); $params = array(
':issue' => $issue->getKey(),
);
$stm_id->execute($params);
// Create or Update the issue itself // Create or Update the issue itself
$issueType = $issue->getIssueType(); $issueType = $issue->getIssueType();
$priority = $issue->getPriority(); $priority = $issue->getPriority();
...@@ -90,4 +93,4 @@ foreach ($projects as $project) { ...@@ -90,4 +93,4 @@ foreach ($projects as $project) {
if ($count >= 1000) break; if ($count >= 1000) break;
} }
echo "$project: $count issue(s) created or updated" . PHP_EOL; echo "$project: $count issue(s) created or updated" . PHP_EOL;
} }
\ No newline at end of file
...@@ -130,7 +130,7 @@ $queries[] = array( ...@@ -130,7 +130,7 @@ $queries[] = array(
'file' => 'extensions-stats.json', 'file' => 'extensions-stats.json',
'archive' => 'monthly', 'archive' => 'monthly',
'query' => " 'query' => "
SELECT COUNT(UNIQUE `name`) AS num_extensions, COUNT(*) AS num_installs SELECT COUNT(DISTINCT(`name`)) AS num_extensions, COUNT(*) AS num_installs
FROM pingback_extension FROM pingback_extension
", ",
); );
......
...@@ -102,4 +102,4 @@ $dbh->query($query); ...@@ -102,4 +102,4 @@ $dbh->query($query);
$result = $dbh->query("SELECT COUNT(DISTINCT `name`) FROM pingback_extension")->fetch(); $result = $dbh->query("SELECT COUNT(DISTINCT `name`) FROM pingback_extension")->fetch();
echo "Unique active extensions: $result[0]" . PHP_EOL; echo "Unique active extensions: $result[0]" . PHP_EOL;
$result = $dbh->query("SELECT COUNT(*) FROM pingback_extension")->fetch(); $result = $dbh->query("SELECT COUNT(*) FROM pingback_extension")->fetch();
echo "Total enabled extensions: $result[0]" . PHP_EOL; echo "Total enabled extensions: $result[0]" . PHP_EOL;
\ 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