Commit aa93b42f authored by cividesk's avatar cividesk

Corrections due to rebuild of Biryani.

parent fea715cb
#! /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
echo "--- CiviCRM Statistics run on `date` ---"
......@@ -19,13 +20,13 @@ done
# Regenerate statistics and push to destination
php generate.php
php historical.php
rsync -a json $DEST
rsync -a json/ $DEST/
# create .htaccess to allow access from anywhere (cf. CORS for $.getJSON)
echo 'Header add Access-Control-Allow-Origin "*"' > $DEST/.htaccess
# 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
echo --- Done ---
echo
\ No newline at end of file
echo
......@@ -35,4 +35,4 @@ foreach ($api->values() as $row) {
echo $errorInfo[2] . PHP_EOL;
}
}
echo "$count CiviCRM-native extensions found in the Extensions Directory." . PHP_EOL;
\ No newline at end of file
echo "$count CiviCRM-native extensions found in the Extensions Directory." . PHP_EOL;
<?php
require_once('config.php');
$directory = __DIR__ . '/json';
foreach (array($directory, "$directory/ext") as $dir) {
if (!file_exists($dir)) {
mkdir($dir);
}
}
// Initialize database
$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
$queries = array();
$files = glob_recursive('generate.inc.php');
......@@ -12,13 +21,6 @@ foreach ($files as $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
foreach ($queries as $query) {
echo "Creating $query[file] ...";
......@@ -47,4 +49,4 @@ function glob_recursive($pattern, $flags = 0) {
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir)
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
return $files;
}
\ No newline at end of file
}
......@@ -48,10 +48,10 @@ foreach($repos as $repo) {
':repository' => $repo,
':hash' => $commit->getSha(),
':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_date' => date('Y-m-d H:i:s', strtotime($commit->getCommit()->getCommitter()->getDate())),
':message' => substr($commit->getCommit()->getMessage(), 0, 1000),
':committer_date' => str_replace(array('T','Z'), ' ', $commit->getCommit()->getCommitter()->getDate()),
':message' => $commit->getCommit()->getMessage(),
);
if ($stm_c->execute($params)) {
$new_commits++;
......@@ -108,4 +108,4 @@ $query = "
WHERE first_commit IS NULL;
";
$dbh->query($query);
echo " $updated updates, $skipped in error." . PHP_EOL;
\ No newline at end of file
echo " $updated updates, $skipped in error." . PHP_EOL;
<?php
$historical = __DIR__ . '/json/historical';
if (!is_dir($historical)) {
mkdir($historical);
}
chdir(__DIR__ . '/../archive/');
$reports = array(
......@@ -28,4 +31,4 @@ foreach($reports as $file => $params) {
$dir = date('Y-m-d', strtotime("$dir + $params[increment]"));
}
file_put_contents("$historical/$file", json_encode($report));
}
\ No newline at end of file
}
......@@ -40,7 +40,10 @@ foreach ($projects as $project) {
$count = 0;
foreach ($walker as $k => $issue) {
// 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
$issueType = $issue->getIssueType();
$priority = $issue->getPriority();
......@@ -90,4 +93,4 @@ foreach ($projects as $project) {
if ($count >= 1000) break;
}
echo "$project: $count issue(s) created or updated" . PHP_EOL;
}
\ No newline at end of file
}
......@@ -130,7 +130,7 @@ $queries[] = array(
'file' => 'extensions-stats.json',
'archive' => 'monthly',
'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
",
);
......
......@@ -102,4 +102,4 @@ $dbh->query($query);
$result = $dbh->query("SELECT COUNT(DISTINCT `name`) FROM pingback_extension")->fetch();
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;
\ No newline at end of file
echo "Total enabled extensions: $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