Commit a3636a2a authored by Arnaud Bey's avatar Arnaud Bey
Browse files

add index && fix delete grid cmd

parent ca6c2731
......@@ -13,11 +13,13 @@ use MagicWordBundle\Entity\Grid;
use MagicWordBundle\Entity\Objective;
use MagicWordBundle\Entity\Round;
use MagicWordBundle\Entity\Score;
use MagicWordBundle\Entity\Wordbox\Acquisition;
use MagicWordBundle\Entity\WrongForm;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Filesystem\Filesystem;
class DeleteGridCommand extends ContainerAwareCommand
......@@ -41,6 +43,9 @@ class DeleteGridCommand extends ContainerAwareCommand
$language = $em->getRepository(Language::class)->find($idLexicon);
echo 'You passed an argument: ' . $idLexicon . "\n\n";
$em->getRepository(Acquisition::class)->deleteByLanguage($language);
$output->writeln('<comment>Suppression acquisitions</comment>');
$games = $em->getRepository(Game::class)->findByLanguage($language);
foreach ($games as $game) {
$scores = $em->getRepository(Score::class)->findByGame($game);
......@@ -60,9 +65,27 @@ class DeleteGridCommand extends ContainerAwareCommand
$output->writeln('<comment>Suppression game ok</comment>');
// delete grid
$rounds = $em->getRepository(Round::class)->findByLanguage($language);
foreach ($rounds as $round) {
$em->remove($round);
}
$em->flush();
$output->writeln('<comment>Suppression Round ok</comment>');
// delete grid
$i = 0;
$grids = $em->getRepository(Grid::class)->findByLanguage($language);
foreach ($grids as $grid) {
$em->remove($grid);
$i++;
if ($i > 500) {
$em->flush();
$i = 0;
$output->writeln('<comment>Suppression grilles...</comment>');
}
}
$em->flush();
$output->writeln('<info>############ SUPPRESSION GRIDS OK #############</info>');
......
......@@ -3,9 +3,12 @@
namespace MagicWordBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Index;
/**
* @ORM\Table(name="foundable_form")
* @ORM\Table(name="foundable_form", indexes={
* @Index(columns={"form"}, name="form"),
* }))
* @ORM\Entity(repositoryClass="MagicWordBundle\Repository\FoundableRepository")
*/
class FoundableForm implements \JsonSerializable
......
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