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
|
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)
|
||||||
{
|
{
|
||||||
parent::__construct($registry, Scrum::class);
|
parent::__construct($registry, Scrum::class);
|
||||||
|
@ -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,67 +144,73 @@ 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"];
|
|
||||||
|
|
||||||
$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();
|
|
||||||
}
|
}
|
||||||
array_push($tbgiteaissues,$giteaissue->number);
|
array_push($tbgiteaissues,$giteaissue->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Bug faudrait placer à closed l'ensemble des issues vu comme open mais qui ne le sont plus
|
||||||
on garde les issues closed
|
if($viewclosed=="false") {
|
||||||
$scrumissues=$scrum->getScrumissues();
|
$scrumissues=$scrum->getScrumissues();
|
||||||
foreach($scrumissues as $scrumissue) {
|
foreach($scrumissues as $scrumissue) {
|
||||||
if(!in_array($scrumissue->getGiteanumber(),$tbgiteaissues)) {
|
if($scrumissue->getGiteastate()=="open"&&!in_array($scrumissue->getGiteanumber(),$tbgiteaissues)) {
|
||||||
$this->_em->remove($scrumissue);
|
$giteaissue=$this->giteaservice->getIssue($scrum->getGiteajson()["owner"]["login"],$scrum->getGiteajson()["name"],$scrumissue->getGiteanumber());
|
||||||
$this->_em->flush();
|
$fgscrumupdate=true;
|
||||||
|
$this->majissue($scrumissue,$giteaissue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if($fgscrumupdate) {
|
if($fgscrumupdate) {
|
||||||
$scrum->setUpdatedate($datescrumupdate);
|
$scrum->setUpdatedate($this->datescrumupdate);
|
||||||
$this->_em->persist($scrum);
|
$this->_em->persist($scrum);
|
||||||
$this->_em->flush();
|
$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