Skip to content

Commit fd2959c

Browse files
authored
Refonte - Événements > Conférences - Liste (#2033)
* Refonte - Événements > Conférences - Liste
1 parent 9e4be91 commit fd2959c

File tree

12 files changed

+489
-64
lines changed

12 files changed

+489
-64
lines changed

app/config/packages/backoffice_menu.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ parameters:
160160
forum_sessions:
161161
nom: 'Conférences'
162162
niveau: 'ROLE_FORUM'
163+
url: '/admin/talk/'
164+
extra_routes:
165+
- admin_talk_list
163166
forum_vote_github:
164167
nom: 'Votes visiteurs'
165168
niveau: 'ROLE_FORUM'

app/config/routing/admin_talk.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
admin_talk_list:
2+
path: /
3+
defaults: {_controller: AppBundle\Controller\Admin\Talk\IndexAction}
4+
15
admin_talk_export_joind_in:
26
path: /export/joind-in/{eventId}/
37
defaults: {_controller: AppBundle\Controller\Admin\Talk\ExportJoindInAction}
@@ -8,6 +12,6 @@ admin_talk_export:
812
path: /export
913
defaults: {_controller: AppBundle\Controller\Admin\Talk\ExportAction}
1014

11-
admin_talk_index:
15+
admin_talk_indexation:
1216
path: /update_indexation
1317
defaults: {_controller: AppBundle\Controller\Admin\Talk\UpdateIndexationAction}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Phinx\Migration\AbstractMigration;
6+
7+
final class PlanningIndexSession extends AbstractMigration
8+
{
9+
public function change(): void
10+
{
11+
$this->table('afup_forum_planning')
12+
->addIndex(['id_session'])
13+
->update();
14+
}
15+
}

htdocs/pages/administration/forum_sessions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
$smarty->assign('forums', $forum->obtenirListe());
6868

69-
$listeSessions = $forum_appel->obtenirListeSessions($_GET['id_forum'], $list_champs, $list_ordre, $list_associatif, $list_filtre,$list_type, $needsMentoring, $planned);
69+
$listeSessions = [];
7070
$moi = $droits->obtenirIdentifiant();
7171
$votant = in_array($_SESSION['afup_login'] ?? '', []);
7272
$maxVotant = count([]);
@@ -102,9 +102,9 @@
102102
} elseif ($action == 'supprimer') {
103103
if ($forum_appel->supprimerSession($_GET['id'])) {
104104
Logs::log('Suppression de la session ' . $_GET['id']);
105-
afficherMessage('La session a été supprimée', 'index.php?page=forum_sessions&action=lister&type=' . $list_type);
105+
afficherMessage('La session a été supprimée', '/admin/talk/');
106106
} else {
107-
afficherMessage('Une erreur est survenue lors de la suppression de la session', 'index.php?page=forum_sessions&action=lister&type=' . $list_type, true);
107+
afficherMessage('Une erreur est survenue lors de la suppression de la session', '/admin/talk/', true);
108108
}
109109
} else {
110110

@@ -298,7 +298,7 @@
298298
} else {
299299
Logs::log('Modification de la session de ' . $formulaire->exportValue('titre') . ' (' . $_GET['id'] . ')');
300300
}
301-
afficherMessage('La session a été ' . (($action == 'ajouter') ? 'ajoutée' : 'modifiée'), 'index.php?page=forum_sessions&action=lister&id_forum=' . $valeurs['id_forum']);
301+
afficherMessage('La session a été ' . (($action == 'ajouter') ? 'ajoutée' : 'modifiée'), '/admin/talk/?id=' . $valeurs['id_forum']);
302302
} else {
303303
$smarty->assign('erreur', 'Une erreur est survenue lors de ' . (($action == 'ajouter') ? "l'ajout" : 'la modification') . ' de la session');
304304
}

sources/Afup/Forum/AppelConferencier.php

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -218,59 +218,6 @@ public function obtenirListeProjets($id_forum = null,
218218
}
219219
}
220220

221-
public function obtenirListeSessions($id_forum = null,
222-
string $champs = 's.*',
223-
string $ordre = 's.date_soumission',
224-
$associatif = false,
225-
$filtre = false,
226-
$type = 'session',
227-
$needsMentoring = null,
228-
$planned = null,
229-
) {
230-
$requete = ' SELECT ';
231-
$requete .= ' COUNT(co.id) as commentaires_nombre, ';
232-
$requete .= ' (SELECT AVG(vote) FROM afup_sessions_vote_github asvg WHERE asvg.session_id = s.session_id) AS note, ';
233-
$requete .= ' (SELECT COUNT(vote) FROM afup_sessions_vote_github asvg WHERE asvg.session_id = s.session_id) AS nb_vote_visiteur, ';
234-
$requete .= ' ' . $champs . ' ';
235-
$requete .= ' FROM ';
236-
$requete .= ' afup_sessions s ';
237-
$requete .= ' LEFT JOIN afup_forum_sessions_commentaires co ';
238-
$requete .= ' ON s.session_id = co.id_session ';
239-
240-
if (null !== $planned) {
241-
$requete .= ' JOIN afup_forum_planning ON (s.session_id = afup_forum_planning.id_session) ';
242-
}
243-
244-
$requete .= ' WHERE s.id_forum = ' . $this->_bdd->echapper($id_forum);
245-
if ($filtre) {
246-
$requete .= ' AND s.titre LIKE \'%' . $filtre . '%\' ';
247-
}
248-
switch ($type) {
249-
case 'session':
250-
$requete .= ' AND s.genre < 9 ';
251-
break;
252-
case 'projet':
253-
$requete .= ' AND s.genre = 9 ';
254-
break;
255-
256-
default:
257-
;
258-
break;
259-
}
260-
261-
if (null !== $needsMentoring) {
262-
$requete .= ' AND s.needs_mentoring = ' . ((int) $needsMentoring);
263-
}
264-
265-
$requete .= ' GROUP BY s.session_id ';
266-
$requete .= ' ORDER BY ' . $ordre;
267-
if ($associatif) {
268-
return $this->_bdd->obtenirAssociatif($requete);
269-
} else {
270-
return $this->_bdd->obtenirTous($requete);
271-
}
272-
}
273-
274221
public function modifierSession(
275222
$id,
276223
$id_forum,
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AppBundle\Controller\Admin\Talk;
6+
7+
use AppBundle\Event\AdminEventSelection;
8+
use AppBundle\Event\Model\Repository\TalkRepository;
9+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
10+
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
11+
use Symfony\Component\Form\Extension\Core\Type\FormType;
12+
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
13+
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
14+
use Symfony\Component\Form\Extension\Core\Type\TextType;
15+
use Symfony\Component\Form\FormFactoryInterface;
16+
use Symfony\Component\Form\FormInterface;
17+
use Symfony\Component\HttpFoundation\Request;
18+
use Symfony\Component\HttpFoundation\Response;
19+
20+
final class IndexAction extends AbstractController
21+
{
22+
public function __construct(
23+
private readonly FormFactoryInterface $formFactory,
24+
private readonly TalkRepository $talkRepository,
25+
) {}
26+
27+
public function __invoke(Request $request, AdminEventSelection $eventSelection): Response
28+
{
29+
//TODO : à supprimer quand les actions via le formulaire auront été migrées
30+
if (isset($_SESSION['flash']['message'])) {
31+
$this->addFlash('notice', $_SESSION['flash']['message']);
32+
}
33+
if (isset($_SESSION['flash']['erreur'])) {
34+
$this->addFlash('error', $_SESSION['flash']['erreur']);
35+
}
36+
unset($_SESSION['flash']);
37+
38+
$event = $eventSelection->event;
39+
40+
$data = [
41+
'id' => $event->getId(),
42+
];
43+
$filterForm = $this->filterForm($data);
44+
$filterForm->handleRequest($request);
45+
46+
if ($filterForm->isSubmitted() && $filterForm->isValid()) {
47+
$data = $filterForm->getData();
48+
$data = array_filter($data);
49+
}
50+
51+
$data['sort_key'] ??= 'talk.date_soumission';
52+
$data['sort_direction'] ??= 'asc';
53+
54+
$sessions = $this->talkRepository->getByEventWithSpeakersAndVotes(
55+
event: $event,
56+
search: $data['q'] ?? '',
57+
orderBy: $data['sort_key'] . ' ' . $data['sort_direction'],
58+
planned: $data['planned'] ?? false,
59+
needMentoring: $data['needs_mentoring'] ?? false,
60+
);
61+
62+
return $this->render('admin/talk/index.html.twig', [
63+
'event' => $event,
64+
'filter_form' => $filterForm,
65+
'filter' => $data,
66+
'event_select_form' => $eventSelection->selectForm(),
67+
'sessions' => $sessions,
68+
]);
69+
}
70+
71+
private function filterForm(array $data): FormInterface
72+
{
73+
return $this->formFactory->createNamedBuilder('', FormType::class, $data, [
74+
'csrf_protection' => false,
75+
])
76+
->setMethod('GET')
77+
->add('q', TextType::class, ['required' => false])
78+
->add('needs_mentoring', CheckboxType::class, ['required' => false])
79+
->add('planned', CheckboxType::class, ['required' => false])
80+
->add('id', HiddenType::class, ['required' => false])
81+
->add('sort_key', HiddenType::class, ['required' => false])
82+
->add('sort_direction', HiddenType::class, ['required' => false])
83+
->add('submit', SubmitType::class)
84+
->getForm();
85+
}
86+
}

sources/AppBundle/Event/Model/Repository/TalkRepository.php

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace AppBundle\Event\Model\Repository;
66

7+
use AppBundle\Event\Model\TalkAggregateVote;
78
use CCMBenchmark\Ting\Repository\Hydrator\AggregateFrom;
89
use CCMBenchmark\Ting\Repository\Hydrator\AggregateTo;
910
use AppBundle\Event\Model\Event;
@@ -74,6 +75,7 @@ public function getTalksBySpeaker(Event $event, Speaker $speaker)
7475

7576
return $query->query($this->getCollection(new HydratorSingleObject()));
7677
}
78+
7779
/**
7880
* @return CollectionInterface&iterable<Talk>
7981
*/
@@ -297,6 +299,67 @@ public function getByEventsWithSpeakers(array $events, $applyPublicationdateFilt
297299
return $aggregates;
298300
}
299301

302+
/**
303+
* @return array<TalkAggregate>
304+
* @throws QueryException
305+
*/
306+
public function getByEventWithSpeakersAndVotes(Event $event, string $search = '', string $orderBy = 'talk.date_soumission ASC', bool $planned = false, bool $needMentoring = false): array
307+
{
308+
$sql = <<<SQL
309+
SELECT talk.id_forum, talk.session_id, titre, skill, genre, abstract, talk.plannifie, talk.language_code,
310+
talk.joindin, talk.youtube_id, talk.slides_url, talk.interview_url, talk.blog_post_url, talk.needs_mentoring,
311+
talk.date_soumission,
312+
speaker.conferencier_id, speaker.nom, speaker.prenom, speaker.id_forum, speaker.photo, speaker.societe,
313+
planning.id, planning.debut, planning.fin, room.id, room.nom,
314+
(SELECT AVG(vote) FROM afup_sessions_vote_github asvg WHERE asvg.session_id = talk.session_id) AS vote_note,
315+
(SELECT COUNT(vote) FROM afup_sessions_vote_github asvg WHERE asvg.session_id = talk.session_id) AS vote_total
316+
FROM afup_sessions AS talk
317+
LEFT JOIN afup_conferenciers_sessions acs ON acs.session_id = talk.session_id
318+
LEFT JOIN afup_conferenciers speaker ON speaker.conferencier_id = acs.conferencier_id
319+
LEFT JOIN afup_forum_planning planning ON planning.id_session = talk.session_id
320+
LEFT JOIN afup_forum_salle room ON planning.id_salle = room.id
321+
WHERE talk.id_forum = :id %s
322+
ORDER BY %s
323+
SQL;
324+
325+
$params = [
326+
'id' => $event->getId(),
327+
];
328+
329+
$where = '';
330+
if ($search) {
331+
$where .= ' AND talk.titre LIKE :search';
332+
$params["search"] = "%{$search}%";
333+
}
334+
if ($planned) {
335+
$where .= ' AND talk.plannifie = 1 AND (talk.date_publication < NOW() OR talk.date_publication IS NULL)';
336+
}
337+
if ($needMentoring) {
338+
$where .= ' AND talk.needs_mentoring = 1';
339+
}
340+
341+
342+
$query = $this
343+
->getPreparedQuery(sprintf($sql, $where, $orderBy))
344+
->setParams($params);
345+
346+
$hydrator = new JoinHydrator();
347+
$hydrator->aggregateOn('talk', 'speaker', 'getId');
348+
$result = $query->query($this->getCollection($hydrator));
349+
350+
$aggregates = [];
351+
foreach ($result as $row) {
352+
$aggregates[] = new TalkAggregate(
353+
$row['talk'],
354+
$row['.aggregation']['speaker'],
355+
$row['room'] ?? null,
356+
$row['planning'] ?? null,
357+
$row[0]->vote_note ? new TalkAggregateVote($row[0]->vote_note, $row[0]->vote_total) : null,
358+
);
359+
}
360+
361+
return $aggregates;
362+
}
300363

301364
/**
302365
* @return CollectionInterface
@@ -379,7 +442,7 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor
379442
->addField([
380443
'columnName' => 'session_id',
381444
'fieldName' => 'id',
382-
'primary' => true,
445+
'primary' => true,
383446
'autoincrement' => true,
384447
'type' => 'int',
385448
])

sources/AppBundle/Event/Model/TalkAggregate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public function __construct(
1212
public array $speakers,
1313
public ?Room $room,
1414
public ?Planning $planning,
15+
public ?TalkAggregateVote $vote = null,
1516
) {}
1617
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AppBundle\Event\Model;
6+
7+
final readonly class TalkAggregateVote
8+
{
9+
public function __construct(
10+
public float $note,
11+
public int $total,
12+
) {}
13+
}

0 commit comments

Comments
 (0)