Commit 30676f54 authored by Arnaud Bey's avatar Arnaud Bey
Browse files

add misc. infos page in administration

parent cb100db6
......@@ -4,6 +4,7 @@ namespace MagicWordBundle\Controller;
use LexiconBundle\Entity\Language;
use LexiconBundle\Entity\Letter;
use MagicWordBundle\Entity\Grid;
use MagicWordBundle\Entity\Rules\ComboPoints;
use MagicWordBundle\Entity\Rules\WordLength;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
......@@ -40,6 +41,24 @@ class AdministrationController extends Controller
return $this->render('MagicWordBundle:Administration:language-edit.html.twig', ['form' => $form, 'language' => $language]);
}
/**
* @Route("/administration/{id}/debug", name="language_debug")
* @Method("GET")
*/
public function debugLanguageAction(Language $language)
{
$bestGrids = $this->getDoctrine()->getRepository(Grid::class)->getBestByLanguage($language);
$worstGrids = $this->getDoctrine()->getRepository(Grid::class)->getWorstByLanguage($language);
$countGrids = $this->getDoctrine()->getRepository(Grid::class)->countAllByLanguage($language);
return $this->render('MagicWordBundle:Administration:language-debug.html.twig', [
'language' => $language,
'bestGrids' => $bestGrids,
'worstGrids' => $worstGrids,
'countGrids' => $countGrids
]);
}
/**
* @Route("/administration/{id}/parameters", name="language_parameters_submit")
* @Method("POST")
......
......@@ -28,6 +28,13 @@ class Grid implements \JsonSerializable
*/
private $side = 4;
/**
* @var int
*
* @ORM\Column(name="foundableCount", type="integer")
*/
private $foundableCount = 0;
/**
* @ORM\OneToMany(targetEntity="FoundableForm", mappedBy="grid", cascade={"remove"})
* @ORM\OrderBy({"points" = "DESC"})
......@@ -240,4 +247,28 @@ class Grid implements \JsonSerializable
{
return $this->squares;
}
/**
* Set foundableCount.
*
* @param int $foundableCount
*
* @return Grid
*/
public function setFoundableCount($foundableCount)
{
$this->foundableCount = $foundableCount;
return $this;
}
/**
* Get foundableCount.
*
* @return int
*/
public function getFoundableCount()
{
return $this->foundableCount;
}
}
......@@ -55,6 +55,8 @@ class FoundableFormManager
$grid->addFoundableForm($foundable);
}
$grid->setFoundableCount(count($foundableForms));
$this->em->persist($grid);
$this->em->flush();
......
......@@ -48,8 +48,45 @@ class GridRepository extends \Doctrine\ORM\EntityRepository
return $query->getOneOrNullResult();
}
public function getBestByLanguage($language)
{
$em = $this->_em;
$dql = "SELECT g FROM MagicWordBundle\Entity\Grid g
WHERE g.language = :language
ORDER BY g.foundableCount DESC";
$query = $em->createQuery($dql);
$query->setParameter('language', $language);
$query->setMaxResults(5);
return $query->getResult();
}
public function getWorstByLanguage($language)
{
$em = $this->_em;
$dql = "SELECT g FROM MagicWordBundle\Entity\Grid g
WHERE g.language = :language
ORDER BY g.foundableCount ASC";
$query = $em->createQuery($dql);
$query->setParameter('language', $language);
$query->setMaxResults(5);
return $query->getResult();
}
public function countAllByLanguage($language)
{
$em = $this->_em;
$dql = "SELECT count(g.id) FROM MagicWordBundle\Entity\Grid g
WHERE g.language = :language";
$query = $em->createQuery($dql);
$query->setParameter('language', $language);
return $query->getSingleScalarResult();
}
public function findNotPlayed($language, $player)
{
......
......@@ -67,6 +67,21 @@
</div>
</div>
</div>
<div class="col-sm-4 mb-2">
<div class="card">
<div class="card-body">
<p class="text-center">
<i class="fas fa-bug fa-3x"></i> {{ "debug" | trans | upper }}
</p>
<p>
Blabla labla Blab laBlabla BlablaBlabla Blabla Blabla
</p>
<a class="btn btn-primary"href="{{ path('language_debug', {'id': language.id}) }}">Editer</a>
</div>
</div>
</div>
</div>
......
{% extends '::base.html.twig' %}
{% block title %}{{ 'letterlanguagepoints' | trans }}{% endblock %}
{% block body -%}
<nav aria-label="breadcrumb">
<ol class="breadcrumb" style="background-color: #fff;">
<li class="breadcrumb-item"><a href="{{path('home')}}">Accueil</a></li>
<li class="breadcrumb-item"><a href="{{path('admin_index')}}">Administration</a></li>
<li class="breadcrumb-item"><a href="{{path('index_language', {id: language.id})}}">{{language.value}}</a></li>
<li class="breadcrumb-item active">Debug</li>
</ol>
</nav>
<div class="card">
<div class="card-body">
<ul class="list-group mb-2">
<li class="list-group-item list-group-item-secondary">Stats</li>
<li class="list-group-item">{{countGrids}} grilles</li>
</ul>
<ul class="list-group mb-2">
<li class="list-group-item list-group-item-secondary">Meilleures grilles</li>
{% for grid in bestGrids %}
<li class="list-group-item">[{{grid.foundableForms|length}}] -
{% for square in grid.squares %}
{{square.letter.value}}
{% endfor %}
</li>
{% endfor %}
</ul>
<ul class="list-group mb-2">
<li class="list-group-item list-group-item-secondary">Moins bonnes grilles</li>
{% for grid in worstGrids %}
<li class="list-group-item">[{{grid.foundableForms|length}}] -
{% for square in grid.squares %}
{{square.letter.value}}
{% endfor %}
</li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment