This commit is contained in:
afornerot 2022-01-13 20:24:04 +01:00
parent d35ae80af5
commit 59f16701a6
5 changed files with 107 additions and 12 deletions

View File

@ -13,6 +13,31 @@ use App\Form\ScrumType as Form;
use App\Service\giteaService;
class ExecutionTime
{
private $startTime;
private $endTime;
public function start(){
$this->startTime = getrusage();
}
public function end(){
$this->endTime = getrusage();
}
private function runTime($ru, $rus, $index) {
return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000))
- ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000));
}
public function __toString(){
return "This process used " . $this->runTime($this->endTime, $this->startTime, "utime") .
" ms for its computations\nIt spent " . $this->runTime($this->endTime, $this->startTime, "stime") .
" ms in system calls\n";
}
}
class ScrumController extends AbstractController
{
private $data = "scrum";
@ -26,6 +51,12 @@ class ScrumController extends AbstractController
{
$em = $this->getDoctrine()->getManager();
$datas = $em->getRepository($this->entity)->findAll();
/*
foreach($datas as $data) {
dump($data->getGiteajson()["name"]);
dump($this->giteaservice->getRepoNotifications($data->getGiteajson()["owner"]["login"],$data->getGiteajson()["name"]));
}
*/
return $this->render($this->render.'list.html.twig',[
$this->data."s" => $datas,
@ -143,6 +174,9 @@ class ScrumController extends AbstractController
public function view($id,Request $request)
{
$executionTime = new ExecutionTime();
$executionTime->start();
// Initialisation de l'enregistrement
$em = $this->getDoctrine()->getManager();
$data=$em->getRepository($this->entity)->find($id);
@ -171,13 +205,15 @@ class ScrumController extends AbstractController
$giteaassignees=[];
$giteateams=$this->giteaservice->getOrgateams($data->getGiteajson()["owner"]["login"]);
if($giteateams) {
if($giteateams&&is_array($giteateams)) {
foreach($giteateams as $team) {
$giteamembers=$this->giteaservice->getTeammembers($team->id);
foreach($giteamembers as $giteamember) {
if(!in_array($giteamember,$giteaassignees))
array_push($giteaassignees,$giteamember);
}
if($giteamembers&&is_array($giteamembers)) {
foreach($giteamembers as $giteamember) {
if(!in_array($giteamember,$giteaassignees))
array_push($giteaassignees,$giteamember);
}
}
}
}
$giteacollaborators=$this->giteaservice->getCollaborators($data->getGiteajson()["owner"]["login"],$data->getGiteajson()["name"]);
@ -269,6 +305,9 @@ class ScrumController extends AbstractController
$filterlabels = $em->getRepository("App:User")->getUserpreference($this->getUser(),"filterlabels",$id);
$filterassignees = $em->getRepository("App:User")->getUserpreference($this->getUser(),"filterassignees",$id);
$executionTime->end();
//dump($executionTime->__toString());
return $this->render($this->render.'view.html.twig', [
'useheader' => true,
'usesidebar' => false,

View File

@ -57,10 +57,27 @@ class Scrum
/**
* @ORM\OneToMany(targetEntity="Scrumissue", mappedBy="scrum", cascade={"persist"}, orphanRemoval=true)
* @ORM\OrderBy({"rowid" = "ASC"})
* @ORM\OrderBy({"giteamilestonename" = "DESC", "rowid" = "ASC"})
*/
private $scrumissues;
public function getStatistique()
{
$id=-100;
$issues=$this->getScrumissues();
$tab=[];
foreach($issues as $issue) {
if($id!=$issue->getGiteamilestone()) {
$id=$issue->getGiteamilestone();
$label=($issue->getGiteamilestonename()?$issue->getGiteamilestonename():"Aucun");
$tab[$id]=[$label,0];
}
$tab[$id][1]=$tab[$id][1]+1;
}
return $tab;
}
public function __construct()
{
$this->users = new ArrayCollection();

View File

@ -93,6 +93,13 @@ class giteaService
return $repos;
}
public function getnotifications() {
$apiurl = $this->url."/notifications?all=true";
$response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken"));
if(!$response||$response->code!="200") return false;
else return $response->body;
}
public function getrepo($id) {
$apiurl = $this->url."/repositories/$id";
$response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken"));
@ -100,6 +107,20 @@ class giteaService
else return $response->body;
}
public function getrepocontents($owner,$name) {
$apiurl = $this->url."/repos/$owner/$name/contents";
$response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken"));
if(!$response||$response->code!="200") return false;
else return $response->body;
}
public function getreponotifications($owner,$name) {
$apiurl = $this->url."/repos/$owner/$name/notifications";
$response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken"));
if(!$response||$response->code!="200") return false;
else return $response->body;
}
public function getlabels($owner,$name) {
$apiurl = $this->url."/repos/$owner/$name/labels";
$response=$this->api("GET",$apiurl,null,$this->session->get("giteatoken"));

View File

@ -1,23 +1,38 @@
{% extends "base.html.twig" %}
{% block localstyle %}
hr { margin:5px 0px 5px 0px; }
{% endblock %}
{% block body %}
<div class="mt-1 mb-3">
<a class="btn btn-success btn-sm" href={{ path('app_scrum_submit') }}><i class="fa fa-plus mr-2"></i>Ajouter un Scrum</a>
</div>
<div>
<div id="grid" class="margin:auto">
{% for scrum in scrums %}
<div class="card float-left mb-1 mr-1" style="width:400px">
<div class="card float-left mb-1 mr-1" style="width:374px">
<div class="card-header">
<a href="{{path('app_scrum_view',{id:scrum.id})}}">{{scrum.name}}</a>
<a class="float-right" href="{{path('app_scrum_update',{id:scrum.id})}}"><i class="fas fa-file"></i></a>
</div>
<div class="card-body">
<p style="min-height:50px">{{scrum.giteajson.description}}</p>
<small><a href="{{scrum.giteajson.html_url}}" target="_blank"">{{scrum.giteajson.html_url}}</a></small>
<small>
<p style="min-height:35px">
{{scrum.giteajson.description}}</p>
Nombre de tickets = {{ scrum.scrumissues|length}}<br>
{% for statistique in scrum.statistique %}
{% if loop.first %}<hr>{%endif%}
{{ statistique[0] }} = {{ statistique[1] }}<br>
{% endfor %}
</small>
</div>
<div class="card-footer small">
<a href="{{scrum.giteajson.html_url}}" target="_blank"">{{scrum.giteajson.html_url}}</a>
</div>
</div>
{% endfor %}
@ -25,5 +40,8 @@
{% block localjavascript %}
$(document).ready(function() {
$('#grid').masonry({
itemSelector: '.card',
});
});
{% endblock %}

View File

@ -337,6 +337,6 @@
}
});
}
});
});
});
{% endblock %}