fix ctrlchange

This commit is contained in:
afornerot 2024-06-15 11:02:32 +02:00
parent b155036347
commit 9171ecbf6c
5 changed files with 40 additions and 37 deletions

View File

@ -404,6 +404,11 @@ class ScrumController extends AbstractController
$filterexcludes = $em->getRepository("App:User")->getUserpreference($this->getUser(),"filterexcludes",$id); $filterexcludes = $em->getRepository("App:User")->getUserpreference($this->getUser(),"filterexcludes",$id);
$showfilters = $em->getRepository("App:User")->getUserpreference($this->getUser(),"showfilters",$id); $showfilters = $em->getRepository("App:User")->getUserpreference($this->getUser(),"showfilters",$id);
// Me demandez pas pourquoi mais j'ai un décallage de 30mn
$updatedate=$data->getUpdatedate();
$updatedate->setTimezone(new \DateTimeZone("UTC"));
$updatedate->add(new \DateInterval("PT30M"));
return $this->render($this->render.'view.html.twig', [ return $this->render($this->render.'view.html.twig', [
'useheader' => true, 'useheader' => true,
'usesidebar' => false, 'usesidebar' => false,
@ -429,6 +434,7 @@ class ScrumController extends AbstractController
'showfilters' => $showfilters, 'showfilters' => $showfilters,
'tbissues' => $tbissues, 'tbissues' => $tbissues,
'tbestim' => $tbestim, 'tbestim' => $tbestim,
'updatedate' => $updatedate,
$this->data => $data, $this->data => $data,
]); ]);
} }

View File

@ -319,42 +319,16 @@ class ScrumissueController extends AbstractController
$id=$request->get('id'); $id=$request->get('id');
$lastupdate=new \DateTime($request->get('lastupdate')); $lastupdate=new \DateTime($request->get('lastupdate'));
$lastupdate->setTimezone(new \DateTimeZone("UTC"));
$lastupdate->add(new \DateInterval("PT1M"));
//var_dump($lastupdate->format(\DateTime::RFC3339_EXTENDED));
$scrum=$em->getRepository("App:Scrum")->find($id); $scrum=$em->getRepository("App:Scrum")->find($id);
if(!$scrum) return new JsonResponse(['message' => 'No Scrum'], 403); if(!$scrum) return new JsonResponse(['message' => 'No Scrum'], 403);
/* $giteaissues=$this->giteaservice->getIssues($scrum->getGiteajson()["owner"]["login"],$scrum->getGiteajson()["name"],"?since=".urlencode($lastupdate->format(\DateTime::RFC3339_EXTENDED)));
$lastupdate=$scrum->getUpdatedate();
$lastupdate->setTimezone(new \DateTimeZone("UTC"));
*/
$giteaissues=$this->giteaservice->getIssues($scrum->getGiteajson()["owner"]["login"],$scrum->getGiteajson()["name"]); return new Response((!empty($giteaissues)?"1":"0"));
if(!is_array($giteaissues)) die("Probleme de connexion avec gitea veuillez vous <a href='/logout'>reconnecter</a>");
foreach($giteaissues as $giteaissue) {
// On ne prend pas les pull request
if(!is_null($giteaissue->pull_request))
continue;
$scrumissue=$em->getRepository("App:Scrumissue")->findOneBy(["scrum"=>$scrum,"giteaid"=>$giteaissue->id]);
if(!$scrumissue) {
return new JsonResponse(true);
}
$fgissueupdated=false;
$updateissue=new \DateTime(json_decode(json_encode($giteaissue), true)["updated_at"]);
$updateissue->setTimezone(new \DateTimeZone("UTC"));
if($updateissue>$lastupdate) {
$fgissueupdated=true;
}
if($fgissueupdated)
return new JsonResponse(true);
}
return new JsonResponse(false);
} }
public function getpoker($userid,$issueid,Request $request) { public function getpoker($userid,$issueid,Request $request) {

View File

@ -236,6 +236,7 @@ class ScrumRepository extends ServiceEntityRepository
} }
if($fgissueupdated) { if($fgissueupdated) {
dump(json_decode(json_encode($giteaissue), true)["updated_at"]);
$updateissue=new \DateTime(json_decode(json_encode($giteaissue), true)["updated_at"]); $updateissue=new \DateTime(json_decode(json_encode($giteaissue), true)["updated_at"]);
$updateissue->setTimezone(new \DateTimeZone("UTC")); $updateissue->setTimezone(new \DateTimeZone("UTC"));
array_push($updatedates,$updateissue); array_push($updatedates,$updateissue);
@ -257,6 +258,7 @@ class ScrumRepository extends ServiceEntityRepository
$this->showtime(false,"Traiter les issues"); $this->showtime(false,"Traiter les issues");
if($fgscrumupdate) { if($fgscrumupdate) {
dump($updatedates);
// Convertir les objets DateTime en timestamps // Convertir les objets DateTime en timestamps
$timestamps = array_map(function($date) { $timestamps = array_map(function($date) {
return $date->getTimestamp(); return $date->getTimestamp();
@ -269,6 +271,8 @@ class ScrumRepository extends ServiceEntityRepository
$mostRecentDate = (new \DateTime())->setTimestamp($mostRecentTimestamp); $mostRecentDate = (new \DateTime())->setTimestamp($mostRecentTimestamp);
// Mettre à jour la date update du scrum // Mettre à jour la date update du scrum
dump($mostRecentDate);
dump("pouet");
$scrum->setUpdatedate($mostRecentDate); $scrum->setUpdatedate($mostRecentDate);
$this->_em->flush(); $this->_em->flush();

View File

@ -3,6 +3,7 @@ namespace App\Twig;
use Twig\Extension\AbstractExtension; use Twig\Extension\AbstractExtension;
use Twig\TwigFilter; use Twig\TwigFilter;
use Twig\TwigFunction;
class AppExtension extends AbstractExtension class AppExtension extends AbstractExtension
{ {
@ -15,6 +16,13 @@ class AppExtension extends AbstractExtension
]; ];
} }
public function getFunctions()
{
return [
new TwigFunction('microtime', [$this, 'getMicrotime']),
];
}
public function urlAvatar($avatar) public function urlAvatar($avatar)
{ {
if(stripos($avatar,"http")===0) if(stripos($avatar,"http")===0)
@ -23,6 +31,11 @@ class AppExtension extends AbstractExtension
return $this->container->getParameter("appAlias")."uploads/avatar/".$avatar; return $this->container->getParameter("appAlias")."uploads/avatar/".$avatar;
} }
public function getMicrotime($asFloat = true)
{
return microtime($asFloat);
}
public function setContainer($container) public function setContainer($container)
{ {
$this->container = $container; $this->container = $container;

View File

@ -54,7 +54,10 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% set start = microtime(true) %}
<div class="d-flex"> <div class="d-flex">
<div id="filters" class="d-flex flex-column pl-2 pr-2 " style="width:350px; background-color:var(--colorbgbodydark);min-height:1500px;"> <div id="filters" class="d-flex flex-column pl-2 pr-2 " style="width:350px; background-color:var(--colorbgbodydark);min-height:1500px;">
<div style="width:100%" class="mt-3"> <div style="width:100%" class="mt-3">
<label class="control-label" style="color:var(--colorftbodydark)">Filtre JALONS</label> <label class="control-label" style="color:var(--colorftbodydark)">Filtre JALONS</label>
@ -453,7 +456,6 @@
</div> </div>
</div> </div>
<div id="mymodalassignees" class="modal" role="dialog"> <div id="mymodalassignees" class="modal" role="dialog">
<div class="modal-dialog modal-lg" role="document"> <div class="modal-dialog modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
@ -481,7 +483,11 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% set end = microtime(true) %}
{% set duration = end - start %}
<p>render time: {{ duration }} seconds</p>
{% endblock %} {% endblock %}
{% block localjavascript %} {% block localjavascript %}
@ -507,7 +513,7 @@
} }
}); });
} }
$(document).ready(function() { $(document).ready(function() {
// Apply Filter // Apply Filter
function showhide() { function showhide() {
@ -1084,7 +1090,7 @@
refreshinfo(); refreshinfo();
$("#mycontent").show(); $("#mycontent").show();
lastupdate="{{scrum.updatedate|date("Ymd H:i:s")}}"; lastupdate="{{updatedate|date("Ymd H:i")}}";
console.log(lastupdate); console.log(lastupdate);
@ -1153,7 +1159,6 @@
}); });
var intervalId = window.setInterval(function(){ var intervalId = window.setInterval(function(){
console.log(lastupdate);
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: "{{path("app_scrumissue_ctrlchange")}}", url: "{{path("app_scrumissue_ctrlchange")}}",
@ -1162,7 +1167,7 @@
lastupdate:lastupdate lastupdate:lastupdate
}, },
success: function(fgupdated) { success: function(fgupdated) {
if(fgupdated) { if(fgupdated=="1") {
$("#haveupdate").show(); $("#haveupdate").show();
} }
} }
@ -1171,6 +1176,7 @@
}); });
function refreshinfo() { function refreshinfo() {
$.ajax({ $.ajax({
method: "POST", method: "POST",