svg
This commit is contained in:
@ -27,9 +27,6 @@ class RedmineService
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les projets accessibles via l'API key.
|
||||
*/
|
||||
public function getProjects(string $apiKey): array
|
||||
{
|
||||
try {
|
||||
@ -51,7 +48,20 @@ class RedmineService
|
||||
}
|
||||
}
|
||||
|
||||
public function getProject(int|string $id, string $apiKey): ?array
|
||||
public function majProject(Project $project, string $apiKey, bool $force = false): void
|
||||
{
|
||||
$updatedAt = $project->getUpdateAt();
|
||||
$updatedMinus10 = $updatedAt instanceof \DateTime ? (clone $updatedAt)->sub(new \DateInterval('PT10M')) : null;
|
||||
|
||||
$redmine = $this->getProject($project->getId(), $apiKey, $updatedMinus10, $force);
|
||||
if ($redmine) {
|
||||
$project->setRedmine($redmine);
|
||||
}
|
||||
$project->setUpdateIssuesAt(new \DateTime());
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
public function getProject(int|string $id, string $apiKey, \DateTimeInterface $date, bool $force = false): ?array
|
||||
{
|
||||
try {
|
||||
$response = $this->client->request('GET', $this->baseUrl.'/projects/'.$id.'.json?include=trackers,issue_categories,issue_custom_fields', [
|
||||
@ -66,6 +76,10 @@ class RedmineService
|
||||
}
|
||||
|
||||
$data = $response->toArray();
|
||||
if (!$force && $date && $data['project']['updated_on'] <= $date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$data['project']['issue_statuses'] = $this->getIssueStatuses($apiKey);
|
||||
$data['project']['issue_priorities'] = $this->getIssuePriorities($apiKey);
|
||||
|
||||
@ -173,8 +187,10 @@ class RedmineService
|
||||
|
||||
public function majProjectIssues(Project $project, string $apiKey, bool $force = false)
|
||||
{
|
||||
$updatedAt = $project->getUpdateAt();
|
||||
$updatedMinus10 = $updatedAt ? (clone $updatedAt)->sub(new \DateInterval('PT10M')) : null;
|
||||
$this->majProject($project, $apiKey, $force);
|
||||
|
||||
$updatedAt = $project->getUpdateIssuesAt();
|
||||
$updatedMinus10 = $updatedAt instanceof \DateTime ? (clone $updatedAt)->sub(new \DateInterval('PT10M')) : null;
|
||||
|
||||
$rissues = $this->getProjectIssues($project->getId(), $apiKey, $force ? null : $updatedMinus10);
|
||||
$rissueids = [];
|
||||
@ -231,7 +247,7 @@ class RedmineService
|
||||
*/
|
||||
|
||||
$this->em->persist($issue);
|
||||
$project->setUpdateAt(new \DateTime());
|
||||
$project->setUpdateIssuesAt(new \DateTime());
|
||||
|
||||
$this->em->flush();
|
||||
}
|
||||
|
Reference in New Issue
Block a user