Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 1 addition & 49 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -4189,24 +4189,12 @@
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIterator\\(\\) on CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Controller\\\\Api\\\\Antennes\\\\GetOneAction\\:\\:transformMeetup\\(\\) return type has no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(AppBundle\\\\Event\\\\Model\\\\Meetup\\)\\: array given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'email\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
Expand Down Expand Up @@ -4802,7 +4790,7 @@
'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Global/HomeAction.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Controller\\\\Website\\\\Global\\\\HomeAction\\:\\:getLatestMeetups\\(\\) should return array\\<AppBundle\\\\Event\\\\Model\\\\Meetup\\> but returns mixed\\.$#',
'message' => '#^Method AppBundle\\\\Controller\\\\Website\\\\Global\\\\HomeAction\\:\\:getLatestMeetups\\(\\) should return array\\<AppBundle\\\\Event\\\\Entity\\\\Meetup\\> but returns mixed\\.$#',
'identifier' => 'return.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Global/HomeAction.php',
Expand Down Expand Up @@ -6127,12 +6115,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Lead.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Meetup\\:\\:getLocation\\(\\) should return string but returns string\\|null\\.$#',
'identifier' => 'return.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Meetup.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot cast mixed to int\\.$#',
'identifier' => 'cast.int',
Expand Down Expand Up @@ -6565,36 +6547,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/InvoiceRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\MeetupRepository\\:\\:findAllForAntenne\\(\\) return type with generic interface CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface does not specify its types\\: T$#',
'identifier' => 'missingType.generics',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\MeetupRepository\\:\\:findNextForAntenne\\(\\) should return AppBundle\\\\Event\\\\Model\\\\Meetup\\|null but returns mixed\\.$#',
'identifier' => 'return.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\MeetupRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\MeetupRepository\\:\\:initMetadata\\(\\) return type with generic class CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata does not specify its types\\: T$#',
'identifier' => 'missingType.generics',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\PlanningRepository\\:\\:getByTalk\\(\\) should return AppBundle\\\\Event\\\\Model\\\\Planning\\|null but returns mixed\\.$#',
'identifier' => 'return.type',
Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/Command/IndexMeetupsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
use Algolia\AlgoliaSearch\SearchClient;
use AppBundle\Antennes\AntenneRepository;
use AppBundle\Event\Model\Repository\MeetupRepository;
use AppBundle\Event\Entity\Repository\MeetupRepository;
use AppBundle\Indexation\Meetups\Runner;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
Expand Down
18 changes: 10 additions & 8 deletions sources/AppBundle/Command/ScrappingMeetupEventsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace AppBundle\Command;

use AppBundle\Event\Model\Repository\MeetupRepository;
use AppBundle\Event\Entity\Repository\MeetupRepository;
use AppBundle\Indexation\Meetups\MeetupClient;
use CuyZ\Valinor\Mapper\MappingError;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -56,16 +56,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($meetups as $meetup) {
$io->progressAdvance();

$id = $meetup->getId();
$existingMeetup = $this->meetupRepository->get($id);
$existingMeetup = null;
if (isset($meetup->id)) {
$existingMeetup = $this->meetupRepository->find($meetup->id);
}

// Si le meetup est d茅j脿 pr茅sent en base, il est mis 脿 jour.
if ($existingMeetup) {
$existingMeetup->setTitle($meetup->getTitle());
$existingMeetup->setDescription($meetup->getDescription());
$existingMeetup->setLocation($meetup->getLocation());
$existingMeetup->setDate($meetup->getDate());
$existingMeetup->setPhotoUrl($meetup->getPhotoUrl());
$existingMeetup->titre = $meetup->titre;
$existingMeetup->description = $meetup->description;
$existingMeetup->lieu = $meetup->lieu;
$existingMeetup->date = $meetup->date;
$existingMeetup->photoUrl = $meetup->photoUrl;

// On doit remplacer la variable, car l'ORM a une r茅f茅rence vers l'instance r茅cup茅r茅e
// via le get et pas celle de la boucle.
Expand Down
18 changes: 9 additions & 9 deletions sources/AppBundle/Controller/Api/Antennes/GetOneAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use AppBundle\Antennes\Antenne;
use AppBundle\Antennes\AntenneRepository;
use AppBundle\Event\Model\Meetup;
use AppBundle\Event\Model\Repository\MeetupRepository;
use AppBundle\Event\Entity\Meetup;
use AppBundle\Event\Entity\Repository\MeetupRepository;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

Expand Down Expand Up @@ -55,7 +55,7 @@ public function __invoke(string $code): JsonResponse

$response['meetups'] = array_map(
fn(Meetup $meetup): array => $this->transformMeetup($antenne, $meetup),
iterator_to_array($allMeetups->getIterator()),
$allMeetups,
);

return new JsonResponse($response);
Expand All @@ -73,12 +73,12 @@ private function createLink(string $prefix, ?string $suffix): ?string
private function transformMeetup(Antenne $antenne, Meetup $meetup): array
{
return [
'title' => $meetup->getTitle(),
'date' => $meetup->getDate()->format('Y-m-d H:i:s'),
'location' => $meetup->getLocation(),
'description' => $meetup->getDescription(),
'url' => 'https://www.meetup.com/fr-FR/' . $antenne->meetup->urlName . '/events/' . $meetup->getId(),
'photo' => $meetup->getPhotoUrl(),
'title' => $meetup->titre,
'date' => $meetup->date->format('Y-m-d H:i:s'),
'location' => $meetup->lieu,
'description' => $meetup->description,
'url' => 'https://www.meetup.com/fr-FR/' . $antenne->meetup->urlName . '/events/' . $meetup->id,
'photo' => $meetup->photoUrl,
];
}
}
4 changes: 2 additions & 2 deletions sources/AppBundle/Controller/Website/Global/HomeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Afup\Site\Corporate\Feuille;
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
use Algolia\AlgoliaSearch\SearchClient;
use AppBundle\Event\Model\Meetup;
use AppBundle\Event\Entity\Meetup;
use AppBundle\Event\Model\Repository\TalkRepository;
use AppBundle\Event\Model\Talk;
use AppBundle\Site\Entity\Repository\ArticleRepository;
Expand Down Expand Up @@ -69,7 +69,7 @@ protected function getLatestMeetups(): array
return [];
}

$cacheKey = 'home_algolia_meetups';
$cacheKey = 'home_algolia_meetups_doctrine';

try {
$cacheItem = $this->cache->getItem($cacheKey);
Expand Down
34 changes: 34 additions & 0 deletions sources/AppBundle/Event/Entity/Meetup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace AppBundle\Event\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'afup_meetup')]
final class Meetup
{
#[ORM\Id]
#[ORM\Column]
public int $id;

#[ORM\Column(name: 'date', type: 'datetime_immutable', nullable: false)]
public \DateTimeImmutable $date;

#[ORM\Column(name: 'title', length: 255, nullable: true)]
public ?string $titre = null;

#[ORM\Column(name: 'location', length: 255, nullable: true)]
public ?string $lieu = null;

#[ORM\Column(length: 255, nullable: true)]
public ?string $description = null;

#[ORM\Column(name: 'antenne_name', length: 255, nullable: false)]
public string $codeAntenne;

#[ORM\Column(length: 255, nullable: true)]
public ?string $photoUrl = null;
}
52 changes: 52 additions & 0 deletions sources/AppBundle/Event/Entity/Repository/MeetupRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace AppBundle\Event\Entity\Repository;

use AppBundle\Antennes\Antenne;
use AppBundle\Doctrine\EntityRepository;
use AppBundle\Event\Entity\Meetup;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Clock\ClockAwareTrait;

/**
* @extends EntityRepository<Meetup>
*/
final class MeetupRepository extends EntityRepository
{
use ClockAwareTrait;

public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Meetup::class);
}

public function findNextForAntenne(Antenne $antenne): ?Meetup
{
/** @var Meetup|null $meetup */
$meetup = ($qb = $this->createQueryBuilder('m'))
->where($qb->expr()->eq('m.codeAntenne', ':codeAntenne'))
->setParameter('codeAntenne', $antenne->code)
->andWhere($qb->expr()->gt('m.date', ':after'))
->setParameter('after', $this->now()->modify('midnight'))
->orderBy('m.date', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();

return $meetup;
}

/**
* @return array<Meetup>
*/
public function findAllForAntenne(Antenne $antenne): array
{
return ($qb = $this->createQueryBuilder('m'))
->where($qb->expr()->eq('m.codeAntenne', ':codeAntenne'))
->setParameter('codeAntenne', $antenne->code)
->getQuery()
->getResult();
}
}
Loading
Loading