Added:
- activity on menu - starting activity page
This commit is contained in:
@@ -5,26 +5,86 @@ namespace App\Controller;
|
||||
use App\Entity\Chapter;
|
||||
use App\Entity\ContentSource;
|
||||
use App\Entity\Manga;
|
||||
use App\Message\DownloadChapter;
|
||||
use App\Repository\ChapterRepository;
|
||||
use App\Repository\MangaRepository;
|
||||
use App\Service\MangadexProvider;
|
||||
use App\Service\MangaScraperService;
|
||||
use App\Service\MangaUpdatesMetadataProvider;
|
||||
use App\Service\SushiScanProviderService;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
class TestController extends AbstractController
|
||||
{
|
||||
public function __construct(private MangadexProvider $mangadexProvider, private MangaRepository $mangaRepository)
|
||||
public function __construct(
|
||||
private MangadexProvider $mangadexProvider,
|
||||
private MangaRepository $mangaRepository,
|
||||
private MessageBusInterface $bus,
|
||||
private Connection $connection,
|
||||
private SerializerInterface $serializer,
|
||||
private readonly ChapterRepository $chapterRepository
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
#[Route('/test', name: 'test')]
|
||||
public function test(): Response
|
||||
{
|
||||
$manga = $this->mangaRepository->find(8);
|
||||
$sqlPending = 'SELECT * FROM messenger_messages WHERE queue_name = :queue';
|
||||
$pending = $this->connection->fetchAllAssociative($sqlPending, ['queue' => 'default']);
|
||||
|
||||
dd($this->mangadexProvider->getFeed($manga));
|
||||
// // Requête pour récupérer les messages en cours de traitement
|
||||
// $sqlProcessing = 'SELECT * FROM messenger_messages WHERE queue_name = :queue AND available_at IS NOT NULL';
|
||||
// $processing = $this->connection->fetchAllAssociative($sqlProcessing, ['queue' => 'default']);
|
||||
|
||||
// dd($pending);
|
||||
$decoded = $this->decodeMessages($pending);
|
||||
|
||||
$status = [];
|
||||
foreach($decoded as $message) {
|
||||
$message = $message['body'];
|
||||
if($message instanceof Envelope) {
|
||||
$chapter = $this->chapterRepository->find($message->getMessage()->getChapterId());
|
||||
$manga = $chapter->getManga();
|
||||
$status[] = [
|
||||
'manga' => $manga->getTitle(),
|
||||
'volume' => $chapter->getVolume(),
|
||||
'chapter' => $chapter->getNumber(),
|
||||
'title' => $chapter->getTitle(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// $this->bus->dispatch(new DownloadChapter(1));
|
||||
|
||||
dd($status);
|
||||
}
|
||||
|
||||
private function decodeMessages(array $messages): array
|
||||
{
|
||||
$decodedMessages = [];
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$decodedMessages[] = [
|
||||
'id' => $message['id'],
|
||||
'body' => $this->decodeMessageBody($message['body']),
|
||||
'headers' => json_decode($message['headers'], true),
|
||||
];
|
||||
}
|
||||
|
||||
return $decodedMessages;
|
||||
}
|
||||
|
||||
private function decodeMessageBody(string $body)
|
||||
{
|
||||
return unserialize(stripcslashes($body));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user