Commit da926a74 authored by cividesk's avatar cividesk

Corrects JIRA collector

parent 34b1a332
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* - full privileges on the DBNAME database * - full privileges on the DBNAME database
* - read privileges on all other databases * - read privileges on all other databases
*/ */
date_default_timezone_set('UTC');
const DBHOST = 'localhost'; const DBHOST = 'localhost';
const DBNAME = 'stats_central'; const DBNAME = 'stats_central';
......
...@@ -48,9 +48,9 @@ foreach($repos as $repo) { ...@@ -48,9 +48,9 @@ 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' => str_replace(array('T','Z'), ' ', $commit->getCommit()->getAuthor()->getDate()), ':author_date' => date('Y-m-d H:i:s', strtotime($commit->getCommit()->getAuthor()->getDate())),
':committer_login' => ($commit->getCommitter() ? $commit->getCommitter()->getLogin() : ''), ':committer_login' => ($commit->getCommitter() ? $commit->getCommitter()->getLogin() : ''),
':committer_date' => str_replace(array('T','Z'), ' ', $commit->getCommit()->getCommitter()->getDate()), ':committer_date' => date('Y-m-d H:i:s', strtotime($commit->getCommit()->getCommitter()->getDate())),
':message' => substr($commit->getCommit()->getMessage(), 0, 1000), ':message' => substr($commit->getCommit()->getMessage(), 0, 1000),
); );
if ($stm_c->execute($params)) { if ($stm_c->execute($params)) {
......
...@@ -40,50 +40,49 @@ foreach ($projects as $project) { ...@@ -40,50 +40,49 @@ 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->bindParam(':issue', $issue->getKey()); $stm_id->execute(array(':issue' => $issue->getKey()));
$stm_id->execute();
// Create or Update the issue itself // Create or Update the issue itself
$stm_ii->bindParam(':jira_id', $issue->getId());
$stm_ii->bindParam(':project', $project);
$stm_ii->bindParam(':issue', $issue->getKey());
$stm_ii->bindParam(':summary', $issue->getSummary());
$issueType = $issue->getIssueType(); $issueType = $issue->getIssueType();
$stm_ii->bindParam(':type', $issueType['name']);
$priority = $issue->getPriority(); $priority = $issue->getPriority();
$stm_ii->bindParam(':priority', $priority['name']);
$security = $issue->get('Security Level'); $security = $issue->get('Security Level');
$stm_ii->bindValue(':security', $security ? $security['name'] : NULL);
$reporter = $issue->getReporter(); $reporter = $issue->getReporter();
$stm_ii->bindParam(':reporter', $reporter['name']);
$assignee = $issue->getAssignee(); $assignee = $issue->getAssignee();
$stm_ii->bindParam(':assignee', $assignee['name']);
$status = $issue->getStatus(); $status = $issue->getStatus();
$stm_ii->bindParam(':status', $status['name']);
$resolution = $issue->getResolution(); $resolution = $issue->getResolution();
$stm_ii->bindParam(':resolution', $resolution['name']); $params = array(
$stm_ii->bindParam(':created', $issue->getCreated()); ':jira_id' => $issue->getId(),
$stm_ii->bindParam(':updated', $issue->getUpdated()); ':project' => $project,
$stm_ii->bindParam(':resolved', $issue->get('Resolved')); ':issue' => $issue->getKey(),
$stm_ii->execute(); ':summary' => substr($issue->getSummary(), 0, 128),
':type' => $issueType['name'],
':priority' => $priority['name'],
':security' => ($security ? $security['name'] : NULL),
':reporter' => $reporter['name'],
':assignee' => $assignee['name'],
':status' => $status['name'],
':resolution' => $resolution['name'],
':created' => date('Y-m-d H:i:s', strtotime($issue->getCreated())),
':updated' => date('Y-m-d H:i:s', strtotime($issue->getUpdated())),
':resolved' => date('Y-m-d H:i:s', strtotime($issue->get('Resolved'))),
);
if (!$stm_ii->execute($params)) {
$errorInfo = $stm_ii->errorInfo();
echo $errorInfo[2] . PHP_EOL;
}
// Clean-up if we already had this issue in the database // Clean-up if we already had this issue in the database
$stm_vd->bindParam(':issue', $issue->getKey()); $stm_vd->execute(array(':issue' => $issue->getKey()));
$stm_vd->execute();
// Create or Update the affects and fix version references // Create or Update the affects and fix version references
$stm_vi->bindParam(':issue', $issue->getKey()); foreach (array('Affects', 'Fix') as $type) {
$type = 'Affects'; $params = array(
$stm_vi->bindParam(':type', $type); ':issue' => $issue->getKey(),
$affects = $issue->get('Affects Version/s'); ':type' => $type,
foreach ($affects as $version) { );
$stm_vi->bindParam(':version', $version['name']); $versions = $issue->get("$type Version/s");
$stm_vi->execute(); foreach ($versions as $version) {
$params[':version'] = $version['name'];
$stm_vi->execute($params);
} }
$type = 'Fix';
$stm_vi->bindParam(':type', $type);
$fixes = $issue->get('Fix Version/s');
foreach ($fixes as $version) {
$stm_vi->bindParam(':version', $version['name']);
$stm_vi->execute();
} }
// Limit as otherwise the walker goes through the whole database // Limit as otherwise the walker goes through the whole database
......
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