This commit is contained in:
afornerot 2023-08-24 13:22:38 +02:00
parent 1b7ac66fe8
commit f1fc009da2
5 changed files with 87 additions and 12 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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 <a href='/ninegitea/logout'>reconnecter</a>");
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);

View File

@ -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;
}