mirror of
https://github.com/quentin-g-dev/afup.git
synced 2026-04-27 02:48:03 +02:00
5c4bc598dc
Cela va permettre d'afficher les stats seulement 2/3 fois par semaine.
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace AppBundle\Command;
|
|
|
|
use Afup\Site\Forum\Inscriptions;
|
|
use AppBundle\Event\Model\Repository\EventRepository;
|
|
use AppBundle\Event\Model\Repository\TicketTypeRepository;
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
class TicketStatsNotificationCommand extends ContainerAwareCommand
|
|
{
|
|
/**
|
|
* @see Command
|
|
*/
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setName('ticket-stats-notification')
|
|
->addOption('display-diff', null, InputOption::VALUE_NONE)
|
|
;
|
|
}
|
|
|
|
/**
|
|
* @see Command
|
|
*/
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$forum_inscriptions = new Inscriptions($GLOBALS['AFUP_DB']);
|
|
$eventReposotory = $this->getContainer()->get('ting')->get(EventRepository::class);
|
|
$ticketRepository = $this->getContainer()->get('ting')->get(TicketTypeRepository::class);
|
|
$event = $eventReposotory->getNextEvent();
|
|
|
|
if (null === $event) {
|
|
return;
|
|
}
|
|
|
|
$date = null;
|
|
|
|
if ($input->getOption('display-diff')) {
|
|
$date = new \DateTime();
|
|
$date->modify('- 1 day');
|
|
}
|
|
|
|
$message = $this->getContainer()->get('app.slack_message_factory')->createMessageForTicketStats(
|
|
$event,
|
|
$forum_inscriptions,
|
|
$ticketRepository,
|
|
$date
|
|
);
|
|
|
|
$this->getContainer()->get('app.slack_notifier')->sendMessage($message);
|
|
}
|
|
}
|