public function indexAction()
 {
     $agrData = [];
     $axis = $series = NULL;
     $success = FALSE;
     $form = new \Application\Forms\JiraForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $cache = $this->getServiceLocator()->get('cache');
             $key = $request->getPost()->get('host');
             // jira host
             $cacheData = $cache->getItem($key, $success);
             if (!$success) {
                 $data = [];
                 $api = new \chobie\Jira\Api($properties->getHost(), new \chobie\Jira\Api\Authentication\Basic($request->getPost()->get('login'), $request->getPost()->get('password')));
                 $walker = new \chobie\Jira\Issues\Walker($api);
                 $walker->push("ORDER BY createdDate");
                 $i = 0;
                 foreach ($walker as $issue) {
                     $data[] = $issue;
                     if ($i == 99) {
                         break;
                     } else {
                         $i++;
                     }
                 }
                 $cache->setItem($key, $data);
             }
             foreach ($cacheData as $node) {
                 if (!array_key_exists($node->getProject()['name'], $agrData)) {
                     $agrData[$node->getProject()['name']] = 0;
                 }
                 if (preg_match('/^\\d{4}-\\d{2}-\\d{2}.*/', $node->getUpdated())) {
                     $agrData[$node->getProject()['name']]++;
                 }
             }
             foreach ($agrData as $key => $value) {
                 $axis .= '\'' . $key . '\',';
                 $series .= $value . ',';
             }
         }
     }
     return new ViewModel(['axis' => $axis, 'series' => $series, 'form' => $form, 'success' => $success]);
 }
<?php

require dirname(__FILE__) . "/common.php";
$api = getApiClient();
/**
 * Jira_Issues_Walker implicitly paging search request.
 * you don't need to care about paging request
 *
 * push(string $jql, string $navigable)
 *
 * `push` function calls Jira_Api::search($jql, $startAt = 0, $maxResult = 20, $fields = '*navigable') internally.
 *
 * @see
 * https://developer.atlassian.com/static/rest/jira/5.0.html#id202584
 */
$walker = new \chobie\Jira\Issues\Walker($api);
$walker->push("project = TICKETACEG AND  updated > -1d ORDER BY priority DESC", "*navigable");
/** okay, then just do foreach walker variable to pull issues */
foreach ($walker as $k => $issue) {
    var_dump($issue);
}
<?php

require dirname(__FILE__) . '/common.php';
$api = getApiClient();
/**
 * Jira_Issues_Walker implicitly paging search request.
 * you don't need to care about paging request
 *
 * push(string $jql, string $navigable)
 *
 * `push` function calls Jira_Api::search($jql, $startAt = 0, $maxResult = 20, $fields = '*navigable') internally.
 *
 * @see https://developer.atlassian.com/static/rest/jira/5.0.html#id202584
 */
$walker = new \chobie\Jira\Issues\Walker($api);
$walker->push('project = TICKETACEG AND  updated > -1d ORDER BY priority DESC', '*navigable');
// Okay, then just do foreach walker variable to pull issues.
foreach ($walker as $issue) {
    var_dump($issue);
}
Example #4
0
<?php

require_once dirname(__DIR__) . '/config.php';
$projects = array('CRM');
// Initialize database and prepared statements
$dbh = new PDO('mysql:dbname=' . DBNAME . ';host=' . DBHOST, DBUSER, DBPASS);
$stm_id = $dbh->prepare("\n  DELETE FROM jira_issue WHERE issue=:issue\n");
$stm_ii = $dbh->prepare("\n  INSERT INTO jira_issue (jira_id, project, issue, summary, type, priority, security, reporter, assignee, status, resolution, created, updated, resolved)\n  VALUES (:jira_id, :project, :issue, :summary, :type, :priority, :security, :reporter, :assignee, :status, :resolution, :created, :updated, :resolved);\n");
$stm_vd = $dbh->prepare("\n  DELETE FROM jira_version WHERE issue=:issue;\n");
$stm_vi = $dbh->prepare("\n  INSERT INTO jira_version (issue, type, version)\n  VALUES (:issue, :type, :version);\n");
// Initialize JIRA REST API
require_once 'common.php';
$api = getApiClient();
$walker = new \chobie\Jira\Issues\Walker($api);
foreach ($projects as $project) {
    // Get the latest updated timestamp from the database and find all issues created or updated after that
    $result = $dbh->query("SELECT MAX(updated) FROM jira_issue WHERE project='{$project}';")->fetch();
    if (empty($result[0])) {
        $result[0] = DATESTART;
    }
    // For some reason JQL does NOT accept seconds in datetime
    $datetime = substr($result[0], 0, -3);
    // the ORDER BY is critical to catching all updated/created issues incrementally
    // DO NOT try to sort based on issueKey as this will break the incremental updates!
    $jqlquery = "project = '{$project}' AND updated >= '{$datetime}' ORDER BY updated ASC";
    $walker->push($jqlquery, "*navigable");
    $count = 0;
    foreach ($walker as $k => $issue) {
        // Clean-up if we already had this issue in the database
        $stm_id->bindParam(':issue', $issue->getKey());
        $stm_id->execute();
Example #5
0
 /**
  * [getIssues description]
  * @param  string $jql [description]
  * @return \chobie\Jira\Issues\Walker      [description]
  */
 public function getIssues($jql)
 {
     $walker = new \chobie\Jira\Issues\Walker($this);
     $walker->push($jql, "*navigable");
     return $walker;
 }