From f1fc009da2a38946014ee3762893fdc00c8827ec Mon Sep 17 00:00:00 2001 From: afornerot Date: Thu, 24 Aug 2023 13:22:38 +0200 Subject: [PATCH] svg --- src/ninegitea-1.0/config/routes.yaml | 4 +++ .../src/Controller/ReportController.php | 36 ++++++++++++++++++- .../src/Controller/ScrumController.php | 24 ++++++++----- .../src/Repository/ScrumRepository.php | 12 ++++++- .../src/Service/giteaService.php | 23 ++++++++++-- 5 files changed, 87 insertions(+), 12 deletions(-) diff --git a/src/ninegitea-1.0/config/routes.yaml b/src/ninegitea-1.0/config/routes.yaml index ba7109d..a9525da 100644 --- a/src/ninegitea-1.0/config/routes.yaml +++ b/src/ninegitea-1.0/config/routes.yaml @@ -173,6 +173,10 @@ app_report_csv: path: /user/report/csv/{id} defaults: { _controller: App\Controller\ReportController:csv } +app_report_test: + path: /user/report/test/{id} + defaults: { _controller: App\Controller\ReportController:test } + #== Scrum ======================================================================================================== app_scrum: path: /user/scrum diff --git a/src/ninegitea-1.0/src/Controller/ReportController.php b/src/ninegitea-1.0/src/Controller/ReportController.php index a66fc50..4933b6a 100755 --- a/src/ninegitea-1.0/src/Controller/ReportController.php +++ b/src/ninegitea-1.0/src/Controller/ReportController.php @@ -32,13 +32,27 @@ class ReportController extends AbstractController $issues=$this->giteaservice->getIssues($repoowner,$reponame,"?state=all"); foreach($issues as $keyissue => $issue) { + // On ne prend pas les pull request + if(!is_null($issue->pull_request)) { + unset($issues[$keyissue]); + continue; + } + $issues[$keyissue]->body = $this->giteaservice->markdown("/".$scrum->getGiteajson()["full_name"],"comment",$issues[$keyissue]->body); $issues[$keyissue]->comments=$this->giteaservice->getIssueComments($repoowner,$reponame,$issue->number); + + /* + Trop lourd foreach($issues[$keyissue]->comments as $keycomment => $comment) { $issues[$keyissue]->comments[$keycomment]->body=$this->giteaservice->markdown("/".$scrum->getGiteajson()["full_name"],"comment",$issues[$keyissue]->comments[$keycomment]->body); } + */ + /* + Trop lourd $issues[$keyissue]->timelines=$this->giteaservice->getIssueTimelines($repoowner,$reponame,$issue->number); + */ + $issues[$keyissue]->timelines=[]; } // Affichage du formulaire @@ -49,7 +63,6 @@ class ReportController extends AbstractController 'repo' => $repo, 'issues' => $issues, ]); - } public function csv($id,Request $request) @@ -100,4 +113,25 @@ class ReportController extends AbstractController return $response; } + + public function test($id,Request $request) + { + $em = $this->getDoctrine()->getManager(); + $scrum = $em->getRepository("App:Scrum")->find($id); + + $em = $this->getDoctrine()->getManager(); + $scrum = $em->getRepository("App:Scrum")->find($id); + $repoid = $scrum->getGiteaid(); + $repoowner = $scrum->getGiteajson()["owner"]["login"]; + $reponame = $scrum->getGiteajson()["name"]; + + $repo=$this->giteaservice->getRepo($repoid); + dump($repo); + dump($repoowner); + $labels=$this->giteaservice->getorglabels($repoowner); + + dump($labels); + + + } } diff --git a/src/ninegitea-1.0/src/Controller/ScrumController.php b/src/ninegitea-1.0/src/Controller/ScrumController.php index dc5b373..2cafa37 100755 --- a/src/ninegitea-1.0/src/Controller/ScrumController.php +++ b/src/ninegitea-1.0/src/Controller/ScrumController.php @@ -245,8 +245,10 @@ class ScrumController extends AbstractController $tbstat[$idmilestone]=["id"=>$idmilestone,"name"=>$lbmilestone,"stat"=>[]]; } - if(!array_key_exists($issue->getScrumcolumn()->getId(),$tbstat[$idmilestone]["stat"])) { - $tbstat[$idmilestone]["stat"][$issue->getScrumcolumn()->getId()]=[ + $ordercolumns=array_search($issue->getScrumcolumn()->getGiteaid(),$giteacolumns); + //$ordercolumns=$issue->getScrumcolumn()->getId(); + if(!array_key_exists($ordercolumns,$tbstat[$idmilestone]["stat"])) { + $tbstat[$idmilestone]["stat"][$ordercolumns]=[ "id"=>$issue->getScrumcolumn()->getId(), "label"=>$issue->getScrumcolumn()->getName(), "total"=>0, @@ -257,30 +259,36 @@ class ScrumController extends AbstractController foreach($labels as $label) { if($issue->getScrumcolumn()->getGiteaid()!=$label["id"]) { - if(!array_key_exists($label["id"],$tbstat[$idmilestone]["stat"][$issue->getScrumcolumn()->getId()]["labels"])) { - $tbstat[$idmilestone]["stat"][$issue->getScrumcolumn()->getId()]["labels"][$label["id"]] = [ + if(!array_key_exists($label["id"],$tbstat[$idmilestone]["stat"][$ordercolumns]["labels"])) { + $tbstat[$idmilestone]["stat"][$ordercolumns]["labels"][$label["id"]] = [ "id"=>$label["id"], "label"=>$label["name"], "total"=>0, "color"=>"#".$label["color"], ]; } - $tbstat[$idmilestone]["stat"][$issue->getScrumcolumn()->getId()]["labels"][$label["id"]]["total"]++; + $tbstat[$idmilestone]["stat"][$ordercolumns]["labels"][$label["id"]]["total"]+=$issue->getWeight(); } } - $tbstat[$idmilestone]["stat"][$issue->getScrumcolumn()->getId()]["total"]++; + $tbstat[$idmilestone]["stat"][$ordercolumns]["total"]+=$issue->getWeight(); } } foreach($tbstat as $k1=>$milestone) { - foreach($milestone["stat"] as $k2=>$statut) { + $tmp=$tbstat[$k1]["stat"]; + ksort($tmp); + $tbstat[$k1]["stat"]=$tmp; + } + + foreach($tbstat as $k1=>$milestone) { + foreach($tbstat[$k1]["stat"] as $k2=>$statut) { $keysort = array_column($tbstat[$k1]["stat"][$k2]["labels"], 'label'); array_multisort($keysort, SORT_ASC, $tbstat[$k1]["stat"][$k2]["labels"]); } - } + return $this->render($this->render.'stat.html.twig', [ 'useheader' => true, 'usesidebar' => false, diff --git a/src/ninegitea-1.0/src/Repository/ScrumRepository.php b/src/ninegitea-1.0/src/Repository/ScrumRepository.php index caded79..a358868 100644 --- a/src/ninegitea-1.0/src/Repository/ScrumRepository.php +++ b/src/ninegitea-1.0/src/Repository/ScrumRepository.php @@ -94,6 +94,7 @@ class ScrumRepository extends ServiceEntityRepository // Récupérer les labels de gitea $gitealabels=$this->giteaservice->getLabels($scrum->getGiteajson()["owner"]["login"],$scrum->getGiteajson()["name"]); + if(!is_array($gitealabels)) die("Probleme de connexion avec gitea veuillez vous reconnecter"); foreach($gitealabels as $key => $gitealabel) { if(in_array($gitealabel->id,$giteacolumns)||in_array($gitealabel->id,$giteateams)||in_array($gitealabel->id,$giteaprioritys)) @@ -164,7 +165,13 @@ class ScrumRepository extends ServiceEntityRepository break; } } - if(!$havecolumn) $scrumissue->setScrumcolumn($firstcolumn); + 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); @@ -173,6 +180,8 @@ class ScrumRepository extends ServiceEntityRepository array_push($tbgiteaissues,$giteaissue->number); } + /* + on garde les issues closed $scrumissues=$scrum->getScrumissues(); foreach($scrumissues as $scrumissue) { if(!in_array($scrumissue->getGiteanumber(),$tbgiteaissues)) { @@ -180,6 +189,7 @@ class ScrumRepository extends ServiceEntityRepository $this->_em->flush(); } } + */ if($fgscrumupdate) { $scrum->setUpdatedate($datescrumupdate); diff --git a/src/ninegitea-1.0/src/Service/giteaService.php b/src/ninegitea-1.0/src/Service/giteaService.php index b4775ba..0a69fe4 100644 --- a/src/ninegitea-1.0/src/Service/giteaService.php +++ b/src/ninegitea-1.0/src/Service/giteaService.php @@ -152,13 +152,32 @@ class giteaService $apiurl = $this->url."/repos/$owner/$name/labels"; $response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken")); if(!$response||$response->code!="200") return false; - else return $response->body; + $label01=$response->body; + + $apiurl = $this->url."/orgs/$owner/labels"; + $response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken")); + if(!$response||$response->code!="200") return false; + $label02=$response->body; + + return array_merge($label01, $label02); } + public function getorglabels($owner) { + $apiurl = $this->url."/orgs/$owner/labels"; + $response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken")); + if(!$response||$response->code!="200") return false; + else return $response->body; + } + public function getlabel($owner,$name,$id) { $apiurl = $this->url."/repos/$owner/$name/labels/$id"; $response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken")); - if(!$response||$response->code!="200") return false; + if(!$response||$response->code!="200") { + $apiurl = $this->url."/orgs/$owner/labels/$id"; + $response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken")); + if(!$response||$response->code!="200") return false; + else return $response->body; + } else return $response->body; }