refresh issue if closed
This commit is contained in:
parent
b58487e075
commit
e15d25236a
@ -12,7 +12,9 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
class ScrumRepository extends ServiceEntityRepository
|
||||
{
|
||||
private $session;
|
||||
|
||||
private $firstcolumn;
|
||||
private $datescrumupdate;
|
||||
|
||||
public function __construct(ManagerRegistry $registry,giteaService $giteaservice,SessionInterface $session)
|
||||
{
|
||||
parent::__construct($registry, Scrum::class);
|
||||
@ -43,8 +45,8 @@ class ScrumRepository extends ServiceEntityRepository
|
||||
else $lastrowid=$last->getRowid();
|
||||
|
||||
// Récupérer la premier column scrum
|
||||
$firstcolumn=$this->_em->getRepository('App:Scrumcolumn')->findOneBy(["scrum"=>$scrum], ['rowid' => 'ASC']);
|
||||
if(!$firstcolumn) return $this->redirectToRoute($this->route."_update",["id"=>$scrum->getId()]);
|
||||
$this->firstcolumn=$this->_em->getRepository('App:Scrumcolumn')->findOneBy(["scrum"=>$scrum], ['rowid' => 'ASC']);
|
||||
if(!$this->firstcolumn) return $this->redirectToRoute($this->route."_update",["id"=>$scrum->getId()]);
|
||||
|
||||
// Récupérer la premier column scrum
|
||||
$columns=$this->_em->getRepository('App:Scrumcolumn')->findBy(["scrum"=>$scrum], ['rowid' => 'ASC']);
|
||||
@ -114,7 +116,7 @@ class ScrumRepository extends ServiceEntityRepository
|
||||
// Génération des issues
|
||||
$tbgiteaissues=[];
|
||||
$fgscrumupdate=false;
|
||||
$datescrumupdate=new \DateTime();
|
||||
$this->datescrumupdate=new \DateTime();
|
||||
|
||||
foreach($giteaissues as $giteaissue) {
|
||||
// On ne prend pas les pull request
|
||||
@ -142,67 +144,73 @@ class ScrumRepository extends ServiceEntityRepository
|
||||
if(!$giteaissue->milestone&&!is_null($scrumissue->getGiteamilestone()))
|
||||
$fgissueupdated=true;
|
||||
|
||||
//$fgissueupdated=true;
|
||||
$fgissueupdated=true;
|
||||
if($fgissueupdated) {
|
||||
$fgscrumupdate=true;
|
||||
if($scrumissue->getGiteajson()["updated_at"]>$datescrumupdate)
|
||||
$datescrumupdate=$scrumissue->getGiteajson()["updated_at"];
|
||||
|
||||
$scrumissue->setGiteanumber($giteaissue->number);
|
||||
$scrumissue->setGiteastate($giteaissue->state);
|
||||
$scrumissue->setGiteatitle($giteaissue->title);
|
||||
if($giteaissue->milestone) {
|
||||
$scrumissue->setGiteamilestone($giteaissue->milestone->id);
|
||||
$scrumissue->setGiteamilestonename($giteaissue->milestone->title);
|
||||
}
|
||||
else {
|
||||
$scrumissue->setGiteamilestone(null);
|
||||
$scrumissue->setGiteamilestonename(null);
|
||||
}
|
||||
$scrumissue->setGiteajson(json_decode(json_encode($giteaissue), true));
|
||||
|
||||
$this->_em->persist($scrumissue);
|
||||
$this->_em->flush();
|
||||
|
||||
$havecolumn=false;
|
||||
foreach($giteaissue->labels as $gitealabel) {
|
||||
$scrumcolumn=$this->_em->getRepository('App:Scrumcolumn')->findOneBy(["giteaid"=>$gitealabel->id]);
|
||||
if($scrumcolumn) {
|
||||
$havecolumn=true;
|
||||
$scrumissue->setScrumcolumn($scrumcolumn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$havecolumn) {
|
||||
$scrumissue->setScrumcolumn($firstcolumn);
|
||||
|
||||
// Affecter le label backlog en tant que gitealabel
|
||||
$backlog=array($firstcolumn->getGiteaid());
|
||||
$this->giteaservice->putIssuelabels($scrumissue->getScrum()->getGiteajson()["owner"]["login"],$scrumissue->getScrum()->getGiteajson()["name"],$scrumissue->getGiteanumber(),$backlog);
|
||||
}
|
||||
|
||||
// Sauvegarde de l'issue
|
||||
$this->_em->persist($scrumissue);
|
||||
$this->_em->flush();
|
||||
$this->majissue($scrumissue,$giteaissue);
|
||||
}
|
||||
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();
|
||||
// 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($datescrumupdate);
|
||||
$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->setGiteastate($giteaissue->state);
|
||||
$scrumissue->setGiteatitle($giteaissue->title);
|
||||
if($giteaissue->milestone) {
|
||||
$scrumissue->setGiteamilestone($giteaissue->milestone->id);
|
||||
$scrumissue->setGiteamilestonename($giteaissue->milestone->title);
|
||||
}
|
||||
else {
|
||||
$scrumissue->setGiteamilestone(null);
|
||||
$scrumissue->setGiteamilestonename(null);
|
||||
}
|
||||
$scrumissue->setGiteajson(json_decode(json_encode($giteaissue), true));
|
||||
|
||||
$this->_em->persist($scrumissue);
|
||||
$this->_em->flush();
|
||||
|
||||
$havecolumn=false;
|
||||
foreach($giteaissue->labels as $gitealabel) {
|
||||
$scrumcolumn=$this->_em->getRepository('App:Scrumcolumn')->findOneBy(["giteaid"=>$gitealabel->id]);
|
||||
if($scrumcolumn) {
|
||||
$havecolumn=true;
|
||||
$scrumissue->setScrumcolumn($scrumcolumn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$havecolumn) {
|
||||
$scrumissue->setScrumcolumn($this->firstcolumn);
|
||||
|
||||
// Affecter le label backlog en tant que gitealabel
|
||||
$backlog=array($this->firstcolumn->getGiteaid());
|
||||
$this->giteaservice->putIssuelabels($scrumissue->getScrum()->getGiteajson()["owner"]["login"],$scrumissue->getScrum()->getGiteajson()["name"],$scrumissue->getGiteanumber(),$backlog);
|
||||
}
|
||||
|
||||
// Sauvegarde de l'issue
|
||||
$this->_em->persist($scrumissue);
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user