Skip to content

Commit

Permalink
page stats de l'admin : on permet de choisis l'event comparé via l'URL
Browse files Browse the repository at this point in the history
réponds partiellement au #1186

cela permet de comparer des événements qui ne sont pas forcément l'événement n-1,
ce qui est utile pour les AFUP Day
  • Loading branch information
agallou committed Feb 4, 2024
1 parent 41d9fa6 commit 6c1b9b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sources/Afup/Forum/Inscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ public function getRegistrationsByReference($reference)
return $registrations;
}

function obtenirSuivi($id_forum)
function obtenirSuivi($id_forum, $id_forum_precedent = null)
{
$forum = new Forum($this->_bdd);
$id_forum_precedent = $forum->obtenirForumPrecedent($id_forum);
if (null === $id_forum_precedent) {
$id_forum_precedent = $forum->obtenirForumPrecedent($id_forum);
}

$now = new \DateTime();
$dateForum = \DateTime::createFromFormat('U', $forum->obtenir($id_forum)['date_fin_vente']);
Expand Down
11 changes: 9 additions & 2 deletions sources/AppBundle/Controller/Admin/Event/StatsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,19 @@ public function __construct(
public function __invoke(Request $request)
{
$id = $request->query->get('id');
$comparedEventId = $request->query->get('compared_event_id');

$event = $this->eventActionHelper->getEventById($id);

$legacyInscriptions = $this->legacyModelFactory->createObject(Inscriptions::class);

$stats = $legacyInscriptions->obtenirSuivi($event->getId());
$comparedSerieName = 'n-1';
if ($comparedEventId) {
$comparedEvent = $this->eventActionHelper->getEventById($comparedEventId, false);
$comparedSerieName = $comparedEvent->getTitle();
}

$stats = $legacyInscriptions->obtenirSuivi($event->getId(), $comparedEventId);
$ticketsDayOne = $this->ticketRepository->getPublicSoldTicketsByDay(Ticket::DAY_ONE, $event);
$ticketsDayTwo = $this->ticketRepository->getPublicSoldTicketsByDay(Ticket::DAY_TWO, $event);

Expand Down Expand Up @@ -93,7 +100,7 @@ public function __invoke(Request $request)
}, $stats['suivi'])),
],
[
'name' => 'n-1',
'name' => $comparedSerieName,
'data' => array_values(array_map(static function ($item) {
return $item['n_1'];
}, $stats['suivi'])),
Expand Down

0 comments on commit 6c1b9b4

Please sign in to comment.