Exemplo n.º 1
0
 public function syncWithJira()
 {
     $staff_list = Staff::all();
     Timelog::where('project_id', '=', $this->id)->delete();
     $issue_service = new IssueService(app(ConfigurationInterface::class));
     $start = 0;
     while (1) {
         try {
             $issues = $issue_service->search("project={$this->jira_key} and timespent>0 and updated >= {$this->start_date}", $start, 250, ["key", "worklog"]);
         } catch (JiraException $exception) {
             return false;
         }
         if (count($issues->getIssues()) == 0) {
             break;
         }
         $timelogs = [];
         foreach ($issues->getIssues() as $issue) {
             $jira_work_logs = $issue->fields->worklog->worklogs;
             foreach ($jira_work_logs as $jira_work_log) {
                 if (!isset($jira_work_log->author)) {
                     continue;
                 }
                 $employee = $staff_list->where('email', $jira_work_log->author->emailAddress)->first();
                 if ($employee == null) {
                     continue;
                 }
                 $timelogs[] = ['project_id' => $this->id, 'staff_id' => $employee->id, 'time_spent' => $jira_work_log->timeSpentSeconds, 'jira_id' => $jira_work_log->id, 'started' => $jira_work_log->started];
             }
         }
         Timelog::insert($timelogs);
         $start += count($issues->getIssues());
     }
     return true;
 }
Exemplo n.º 2
0
 public function testSearch()
 {
     $this->markTestSkipped();
     $jql = 'project not in (TEST)  and assignee = currentUser() and status in (Resolved, closed)';
     try {
         $issueService = new IssueService();
         $ret = $issueService->search($jql);
         foreach ($ret as $issue) {
             Dumper::dump($issue);
         }
     } catch (JiraException $e) {
         $this->assertTrue(false, 'testSearch Failed : ' . $e->getMessage());
     }
 }
 public function testSearch()
 {
     $jql = 'project not in (TEST)  and assignee = currentUser() and status in (Resolved, closed)';
     try {
         $issueService = new IssueService();
         $ret = $issueService->search($jql);
         var_dump($ret);
     } catch (JIRAException $e) {
         $this->assertTrue(false, 'testSearch Failed : ' . $e->getMessage());
     }
 }