refresh issue if closed

This commit is contained in:
afornerot 2023-08-29 17:07:47 +02:00
parent b58487e075
commit e15d25236a
1 changed files with 61 additions and 53 deletions

View File

@ -12,6 +12,8 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
class ScrumRepository extends ServiceEntityRepository class ScrumRepository extends ServiceEntityRepository
{ {
private $session; private $session;
private $firstcolumn;
private $datescrumupdate;
public function __construct(ManagerRegistry $registry,giteaService $giteaservice,SessionInterface $session) public function __construct(ManagerRegistry $registry,giteaService $giteaservice,SessionInterface $session)
{ {
@ -43,8 +45,8 @@ class ScrumRepository extends ServiceEntityRepository
else $lastrowid=$last->getRowid(); else $lastrowid=$last->getRowid();
// Récupérer la premier column scrum // Récupérer la premier column scrum
$firstcolumn=$this->_em->getRepository('App:Scrumcolumn')->findOneBy(["scrum"=>$scrum], ['rowid' => 'ASC']); $this->firstcolumn=$this->_em->getRepository('App:Scrumcolumn')->findOneBy(["scrum"=>$scrum], ['rowid' => 'ASC']);
if(!$firstcolumn) return $this->redirectToRoute($this->route."_update",["id"=>$scrum->getId()]); if(!$this->firstcolumn) return $this->redirectToRoute($this->route."_update",["id"=>$scrum->getId()]);
// Récupérer la premier column scrum // Récupérer la premier column scrum
$columns=$this->_em->getRepository('App:Scrumcolumn')->findBy(["scrum"=>$scrum], ['rowid' => 'ASC']); $columns=$this->_em->getRepository('App:Scrumcolumn')->findBy(["scrum"=>$scrum], ['rowid' => 'ASC']);
@ -114,7 +116,7 @@ class ScrumRepository extends ServiceEntityRepository
// Génération des issues // Génération des issues
$tbgiteaissues=[]; $tbgiteaissues=[];
$fgscrumupdate=false; $fgscrumupdate=false;
$datescrumupdate=new \DateTime(); $this->datescrumupdate=new \DateTime();
foreach($giteaissues as $giteaissue) { foreach($giteaissues as $giteaissue) {
// On ne prend pas les pull request // On ne prend pas les pull request
@ -142,11 +144,37 @@ class ScrumRepository extends ServiceEntityRepository
if(!$giteaissue->milestone&&!is_null($scrumissue->getGiteamilestone())) if(!$giteaissue->milestone&&!is_null($scrumissue->getGiteamilestone()))
$fgissueupdated=true; $fgissueupdated=true;
//$fgissueupdated=true; $fgissueupdated=true;
if($fgissueupdated) { if($fgissueupdated) {
$fgscrumupdate=true; $fgscrumupdate=true;
if($scrumissue->getGiteajson()["updated_at"]>$datescrumupdate) $this->majissue($scrumissue,$giteaissue);
$datescrumupdate=$scrumissue->getGiteajson()["updated_at"]; }
array_push($tbgiteaissues,$giteaissue->number);
}
// Bug faudrait placer à closed l'ensemble des issues vu comme open mais qui ne le sont plus
if($viewclosed=="false") {
$scrumissues=$scrum->getScrumissues();
foreach($scrumissues as $scrumissue) {
if($scrumissue->getGiteastate()=="open"&&!in_array($scrumissue->getGiteanumber(),$tbgiteaissues)) {
$giteaissue=$this->giteaservice->getIssue($scrum->getGiteajson()["owner"]["login"],$scrum->getGiteajson()["name"],$scrumissue->getGiteanumber());
$fgscrumupdate=true;
$this->majissue($scrumissue,$giteaissue);
}
}
}
if($fgscrumupdate) {
$scrum->setUpdatedate($this->datescrumupdate);
$this->_em->persist($scrum);
$this->_em->flush();
}
}
function majissue($scrumissue,$giteaissue) {
if($scrumissue->getGiteajson()["updated_at"]>$this->datescrumupdate)
$this->datescrumupdate=$scrumissue->getGiteajson()["updated_at"];
$scrumissue->setGiteanumber($giteaissue->number); $scrumissue->setGiteanumber($giteaissue->number);
$scrumissue->setGiteastate($giteaissue->state); $scrumissue->setGiteastate($giteaissue->state);
@ -174,10 +202,10 @@ class ScrumRepository extends ServiceEntityRepository
} }
} }
if(!$havecolumn) { if(!$havecolumn) {
$scrumissue->setScrumcolumn($firstcolumn); $scrumissue->setScrumcolumn($this->firstcolumn);
// Affecter le label backlog en tant que gitealabel // Affecter le label backlog en tant que gitealabel
$backlog=array($firstcolumn->getGiteaid()); $backlog=array($this->firstcolumn->getGiteaid());
$this->giteaservice->putIssuelabels($scrumissue->getScrum()->getGiteajson()["owner"]["login"],$scrumissue->getScrum()->getGiteajson()["name"],$scrumissue->getGiteanumber(),$backlog); $this->giteaservice->putIssuelabels($scrumissue->getScrum()->getGiteajson()["owner"]["login"],$scrumissue->getScrum()->getGiteajson()["name"],$scrumissue->getGiteanumber(),$backlog);
} }
@ -185,24 +213,4 @@ class ScrumRepository extends ServiceEntityRepository
$this->_em->persist($scrumissue); $this->_em->persist($scrumissue);
$this->_em->flush(); $this->_em->flush();
} }
array_push($tbgiteaissues,$giteaissue->number);
}
/*
on garde les issues closed
$scrumissues=$scrum->getScrumissues();
foreach($scrumissues as $scrumissue) {
if(!in_array($scrumissue->getGiteanumber(),$tbgiteaissues)) {
$this->_em->remove($scrumissue);
$this->_em->flush();
}
}
*/
if($fgscrumupdate) {
$scrum->setUpdatedate($datescrumupdate);
$this->_em->persist($scrum);
$this->_em->flush();
}
}
} }