Skip to content
Merged
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
9 changes: 8 additions & 1 deletion app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ services:
autowire: true
public: true


app.github.http_client:
class: GuzzleHttp\Client
arguments:
Expand All @@ -717,3 +716,11 @@ services:
AppBundle\Github\GithubClient:
arguments:
$githubClient: '@app.github.http_client'

app.meetup.http_client:
class: GuzzleHttp\Client

AppBundle\Indexation\Meetups\MeetupClient:
arguments:
$httpClient: '@app.meetup.http_client'
$antennesCollection: '@AppBundle\Antennes\AntennesCollection'
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"captioning/captioning": "^2.6",
"ccmbenchmark/ting_bundle": "3.4.1",
"cocur/slugify": "^2.3",
"cuyz/valinor": "^0.17.1",
"doctrine/dbal": "^2.5",
"ekino/newrelic-bundle": "^1.4",
"erusev/parsedown": "^1.6",
Expand Down
76 changes: 75 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions db/migrations/20250209185223_meetup_emojis.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

class MeetupEmojis extends AbstractMigration
{
public function change(): void
{
$this->execute("ALTER TABLE afup_meetup CHANGE description description text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;");
$this->execute("ALTER TABLE afup_meetup CHANGE title title varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;");
}
}
63 changes: 16 additions & 47 deletions sources/AppBundle/Command/ScrappingMeetupEventsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace AppBundle\Command;

use AppBundle\Event\Model\Repository\MeetupRepository;
use AppBundle\Indexation\Meetups\MeetupScraper;
use AppBundle\Indexation\Meetups\MeetupClient;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\LockableTrait;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -16,9 +16,6 @@ class ScrappingMeetupEventsCommand extends ContainerAwareCommand
{
use LockableTrait;

/**
* @see Command
*/
protected function configure(): void
{
$this
Expand All @@ -28,12 +25,6 @@ protected function configure(): void
;
}

/**
*
* @see Command
*
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
Expand All @@ -47,54 +38,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int

try {
$ting = $this->getContainer()->get('ting');
$meetupScraper = new MeetupScraper();
$meetups = $meetupScraper->getEvents();

/** @var MeetupClient $meetupClient */
$meetupClient = $this->getContainer()->get(MeetupClient::class);
$meetups = $meetupClient->getEvents();

$meetupRepository = $ting->get(MeetupRepository::class);

$emlementsLength = $this->countAllNestedElements($meetups);
$io->progressStart($emlementsLength);
foreach ($meetups as $antenneMeetups) {
foreach ($antenneMeetups as $meetup) {
$io->progressAdvance();
$io->progressStart(count($meetups));
foreach ($meetups as $meetup) {
$io->progressAdvance();

$id =$meetup->getId();
$existingMeetup = $meetupRepository->get($id);
if (!$existingMeetup) {
$meetupRepository->save($meetup);
} else {
$io->note(sprintf('Meetup id %d déjà en base.', $id));
}
$id = $meetup->getId();
$existingMeetup = $meetupRepository->get($id);
if (!$existingMeetup) {
$meetupRepository->save($meetup);
} else {
$io->note(sprintf('Meetup id %d déjà en base.', $id));
}
}

$io->progressFinish();
$io->success('Terminé avec succès');

return 1;
} catch (\Exception $e) {
throw new \Exception('Problème lors du scraping ou de la sauvegarde des évènements Meetup', $e->getCode(), $e);
}
}

/**
* Permet de faire un count sur un tableau multi-dimensionnel
*
* @param $array
*
* @return int
*/
private function countAllNestedElements($array)
{
$count = 0;

foreach ($array as $element) {
if (is_array($element)) {
// Si l'élément est un tableau, on appelle récursivement la fonction
$count += $this->countAllNestedElements($element);
} else {
$count++;
}
}

return $count;
}
}
18 changes: 18 additions & 0 deletions sources/AppBundle/Indexation/Meetups/GraphQL/Edge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace AppBundle\Indexation\Meetups\GraphQL;

/**
* @readonly
*/
final class Edge
{
public Node $node;

public function __construct(Node $node)
{
$this->node = $node;
}
}
22 changes: 22 additions & 0 deletions sources/AppBundle/Indexation/Meetups/GraphQL/Events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace AppBundle\Indexation\Meetups\GraphQL;

/**
* @readonly
*/
final class Events
{
/** @var list<Edge> */
public array $edges;

/**
* @param list<Edge> $edges
*/
public function __construct(array $edges)
{
$this->edges = $edges;
}
}
20 changes: 20 additions & 0 deletions sources/AppBundle/Indexation/Meetups/GraphQL/Group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace AppBundle\Indexation\Meetups\GraphQL;

/**
* @readonly
*/
final class Group
{
public Events $upcomingEvents;
public Events $pastEvents;

public function __construct(Events $upcomingEvents, Events $pastEvents)
{
$this->upcomingEvents = $upcomingEvents;
$this->pastEvents = $pastEvents;
}
}
28 changes: 28 additions & 0 deletions sources/AppBundle/Indexation/Meetups/GraphQL/Node.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace AppBundle\Indexation\Meetups\GraphQL;

use DateTime;

/**
* @readonly
*/
final class Node
{
public string $id;
public string $title;
public string $description;
public DateTime $dateTime;
public ?Venue $venue;

public function __construct(string $id, string $title, string $description, DateTime $dateTime, ?Venue $venue)
{
$this->id = $id;
$this->title = $title;
$this->description = $description;
$this->dateTime = $dateTime;
$this->venue = $venue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace AppBundle\Indexation\Meetups\GraphQL;

/**
* @readonly
*/
final class QueryGroupsResponse
{
/** @var array<string, Group> */
public array $data;

/**
* @param array<string, Group> $data
*/
public function __construct(array $data)
{
$this->data = $data;
}
}
18 changes: 18 additions & 0 deletions sources/AppBundle/Indexation/Meetups/GraphQL/Venue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace AppBundle\Indexation\Meetups\GraphQL;

/**
* @readonly
*/
final class Venue
{
public string $name;

public function __construct(string $name)
{
$this->name = $name;
}
}
Loading