Compare commits

..

No commits in common. "351bffb298989f0ce55eb56405f8bf5e3ce97087" and "690b849ca60b8761688843d4966ace01980c26a5" have entirely different histories.

41 changed files with 208 additions and 316 deletions

View File

@ -12,7 +12,6 @@
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.14",
"jms/serializer-bundle": "^5.2",
"knplabs/knp-paginator-bundle": "^6.2",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.16",
"sensio/framework-extra-bundle": "^6.1",

162
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "adf20c9a601a7f685ece9da4a4ac9e47",
"content-hash": "3e4ae473183073d1dd231517f5734c3e",
"packages": [
{
"name": "doctrine/annotations",
@ -2013,166 +2013,6 @@
],
"time": "2023-02-05T11:03:45+00:00"
},
{
"name": "knplabs/knp-components",
"version": "v4.1.0",
"source": {
"type": "git",
"url": "https://github.com/KnpLabs/knp-components.git",
"reference": "6b6efa81ee894e325744bf785d50dc962937b1f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/KnpLabs/knp-components/zipball/6b6efa81ee894e325744bf785d50dc962937b1f2",
"reference": "6b6efa81ee894e325744bf785d50dc962937b1f2",
"shasum": ""
},
"require": {
"php": "^8.0",
"symfony/event-dispatcher-contracts": "^3.0"
},
"conflict": {
"doctrine/dbal": "<2.10"
},
"require-dev": {
"doctrine/mongodb-odm": "^2.4",
"doctrine/orm": "^2.12",
"doctrine/phpcr-odm": "^1.6",
"ext-pdo_sqlite": "*",
"jackalope/jackalope-doctrine-dbal": "^1.8",
"phpunit/phpunit": "^9.5",
"propel/propel1": "^1.7",
"ruflin/elastica": "^7.0",
"solarium/solarium": "^6.0",
"symfony/http-foundation": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"symfony/property-access": "^5.4 || ^6.0"
},
"suggest": {
"doctrine/common": "to allow usage pagination with Doctrine ArrayCollection",
"doctrine/mongodb-odm": "to allow usage pagination with Doctrine ODM MongoDB",
"doctrine/orm": "to allow usage pagination with Doctrine ORM",
"doctrine/phpcr-odm": "to allow usage pagination with Doctrine ODM PHPCR",
"propel/propel1": "to allow usage pagination with Propel ORM",
"ruflin/elastica": "to allow usage pagination with ElasticSearch Client",
"solarium/solarium": "to allow usage pagination with Solarium Client",
"symfony/http-foundation": "to retrieve arguments from Request",
"symfony/property-access": "to allow sorting arrays"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
}
},
"autoload": {
"psr-4": {
"Knp\\Component\\": "src/Knp/Component"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "KnpLabs Team",
"homepage": "https://knplabs.com"
},
{
"name": "Symfony Community",
"homepage": "https://github.com/KnpLabs/knp-components/contributors"
}
],
"description": "Knplabs component library",
"homepage": "http://github.com/KnpLabs/knp-components",
"keywords": [
"components",
"knp",
"knplabs",
"pager",
"paginator"
],
"support": {
"issues": "https://github.com/KnpLabs/knp-components/issues",
"source": "https://github.com/KnpLabs/knp-components/tree/v4.1.0"
},
"time": "2022-12-19T09:36:54+00:00"
},
{
"name": "knplabs/knp-paginator-bundle",
"version": "v6.2.0",
"source": {
"type": "git",
"url": "https://github.com/KnpLabs/KnpPaginatorBundle.git",
"reference": "8da698f0856b1d9c9c02dcacbfc382c5c9440c80"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/KnpLabs/KnpPaginatorBundle/zipball/8da698f0856b1d9c9c02dcacbfc382c5c9440c80",
"reference": "8da698f0856b1d9c9c02dcacbfc382c5c9440c80",
"shasum": ""
},
"require": {
"knplabs/knp-components": "^4.1",
"php": "^8.0",
"symfony/config": "^6.0",
"symfony/dependency-injection": "^6.0",
"symfony/event-dispatcher": "^6.0",
"symfony/http-foundation": "^6.0",
"symfony/http-kernel": "^6.0",
"symfony/routing": "^6.0",
"symfony/translation": "^6.0",
"twig/twig": "^3.0"
},
"require-dev": {
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9.5",
"symfony/expression-language": "^6.0",
"symfony/templating": "^6.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "5.x-dev"
}
},
"autoload": {
"psr-4": {
"Knp\\Bundle\\PaginatorBundle\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "KnpLabs Team",
"homepage": "https://knplabs.com"
},
{
"name": "Symfony Community",
"homepage": "https://github.com/KnpLabs/KnpPaginatorBundle/contributors"
}
],
"description": "Paginator bundle for Symfony to automate pagination and simplify sorting and other features",
"homepage": "https://github.com/KnpLabs/KnpPaginatorBundle",
"keywords": [
"bundle",
"knp",
"knplabs",
"pager",
"pagination",
"paginator",
"symfony"
],
"support": {
"issues": "https://github.com/KnpLabs/KnpPaginatorBundle/issues",
"source": "https://github.com/KnpLabs/KnpPaginatorBundle/tree/v6.2.0"
},
"time": "2023-03-25T06:51:40+00:00"
},
{
"name": "monolog/monolog",
"version": "3.3.1",

View File

@ -1,5 +1,4 @@
<?php
declare(strict_types=1);
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
@ -14,5 +13,4 @@ return [
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
];

View File

@ -1,4 +0,0 @@
# https://github.com/KnpLabs/KnpPaginatorBundle#yaml
knp_paginator:
template:
pagination: 'KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig'

View File

@ -12,20 +12,14 @@ services:
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
# TODO: fix retrieval
# Point Tools
$appUserId: 435
$appUserLogin: 'point-tools'
# Telegram Bot API
$telegramToken: ''
$debugEnabled: '%kernel.debug%'
# Point API
$pointDomain: 'point.im'
$pointScheme: 'https'
$pointApiDelay: 5000
$pointApiDelay: ''
$pointAppUserId: ''
$pointApiClient: '@app.point.http_client'
# Crawler API
$crawlerToken: ''
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
@ -37,8 +31,8 @@ services:
- '../src/Kernel.php'
# HTTP client for Point API
app.point.http_client:
class: Symfony\Component\HttpClient\HttpClient
Symfony\Component\HttpClient\HttpClient:
alias: 'app.point.http_client'
factory: [null, 'create']
arguments:
base_uri: '%point_base_url%'

View File

@ -83,6 +83,10 @@ knp_markdown:
parser:
service: app.point.markdown_parser
knp_paginator:
template:
pagination: KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig
csa_guzzle:
profiler: '%kernel.debug%'

View File

@ -1,7 +1,6 @@
<?php
declare(strict_types=1);
namespace App\Controller\Api;
namespace src\PointToolsBundle\Controller\Api;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
@ -16,6 +15,9 @@ class AbstractApiController extends AbstractController
], $code);
}
/**
*
*/
protected function createErrorResponse(string $message, int $code = 400): Response
{
return $this->json([
@ -26,4 +28,4 @@ class AbstractApiController extends AbstractController
]
], $code);
}
}
}

View File

@ -1,19 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Controller\Api;
namespace src\PointToolsBundle\Controller\Api;
use App\DTO\Api\PostsPage;
use App\Factory\Blog\PostFactory;
use Doctrine\ORM\EntityManagerInterface;
use JMS\Serializer\SerializerInterface;
use src\PointToolsBundle\DTO\Api\PostsPage;
use src\PointToolsBundle\Service\Factory\Blogs\PostFactory;
use Symfony\Component\HttpFoundation\{Request, Response};
use src\PointToolsBundle\Controller\Api\AbstractApiController;
class CrawlerController extends AbstractApiController
{
public function __construct(
private readonly string $crawlerToken,
) {
/** @var string */
private $crawlerToken;
public function __construct(string $crawlerToken)
{
$this->crawlerToken = $crawlerToken;
}
public function receiveAllPageAction(Request $request, SerializerInterface $serializer, PostFactory $postFactory, EntityManagerInterface $em): Response
@ -21,10 +24,7 @@ class CrawlerController extends AbstractApiController
$remoteToken = $request->request->get('token');
if (!$this->crawlerToken || ($this->crawlerToken !== $remoteToken)) {
return $this->createErrorResponse(
'Token error. Please check it in crawler and API parameters.',
Response::HTTP_FORBIDDEN,
);
return $this->createErrorResponse('Token error. Please check it in crawler and API parameters.', Response::HTTP_FORBIDDEN);
}
$json = $request->request->get('json');

View File

@ -1,12 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Controller;
namespace src\PointToolsBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use App\Entity\{SubscriptionEvent, User};
use App\Repository\SubscriptionEventRepository;
use Symfony\Component\HttpFoundation\{JsonResponse, Response};
use src\PointToolsBundle\Entity\User;
use src\PointToolsBundle\Entity\{SubscriptionEvent};
use src\PointToolsBundle\Repository\SubscriptionEventRepository;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class ApiController
{

View File

@ -1,10 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Controller;
namespace src\PointToolsBundle\Controller;
use Knp\Component\Pager\PaginatorInterface;
use App\Repository\SubscriptionEventRepository;
use src\PointToolsBundle\Repository\SubscriptionEventRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response};

View File

@ -1,22 +1,30 @@
<?php
declare(strict_types=1);
namespace App\Controller;
namespace src\PointToolsBundle\Controller;
use App\Form\UserSearchType;
use App\Repository\{SubscriptionEventRepository, SubscriptionRepository, UserRepository};
use Doctrine\ORM\EntityManager;
use src\PointToolsBundle\Form\UserSearchType;
use src\PointToolsBundle\Repository\SubscriptionRepository;
use src\PointToolsBundle\Repository\UserRepository;
use src\PointToolsBundle\Repository\{SubscriptionEventRepository};
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\{JsonResponse, Request, Response};
class MainController extends AbstractController
{
private const AJAX_AUTOCOMPLETE_SIZE = 10;
const AJAX_AUTOCOMPLETE_SIZE = 10;
public function __construct(
private readonly int $appUserId,
private readonly string $appUserLogin,
) {
/** @var int */
private $appUserId;
/** @var string */
private $appUserLogin;
public function __construct(int $appUserId, string $appUserLogin)
{
$this->appUserId = $appUserId;
$this->appUserLogin = $appUserLogin;
}
public function indexAction(
@ -25,6 +33,9 @@ class MainController extends AbstractController
SubscriptionRepository $subscriptionRepository,
SubscriptionEventRepository $subscriptionEventRepository
): Response {
/** @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
$form = $this->createForm(
UserSearchType::class,
null,
@ -55,9 +66,17 @@ class MainController extends AbstractController
]);
}
/** Returns user search autocomplete data in JSON */
public function searchUserAjaxAction(string $login, UserRepository $userRepository): JsonResponse
/**
* Returns user search autocomplete data in JSON
*
* @param string $login
*
* @return JsonResponse
*/
public function searchUserAjaxAction(string $login, UserRepository $userRepository): Response
{
$em = $this->getDoctrine()->getManager();
$result = [];
foreach ($userRepository->findUsersLikeLogin($login, self::AJAX_AUTOCOMPLETE_SIZE) as $user) {

View File

@ -1,12 +1,11 @@
<?php
declare(strict_types=1);
namespace App\Controller;
namespace src\PointToolsBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use App\Entity\Blog\Post;
use App\Repository\Blog\PostRepository;
use src\PointToolsBundle\Entity\Blogs\Post;
use src\PointToolsBundle\Repository\Blogs\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Response;
class PostController extends AbstractController
@ -30,4 +29,5 @@ class PostController extends AbstractController
'post' => $postRepository->getPostWithComments($post->getId()),
]);
}
}

View File

@ -1,18 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Controller;
namespace src\PointToolsBundle\Controller;
use Knp\Component\Pager\PaginatorInterface;
use App\Repository\Blog\PostRepository;
use src\PointToolsBundle\Repository\Blogs\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Request;
class PublicFeedController extends AbstractController
{
private const POSTS_PER_PAGE = 20;
public function indexAction(Request $request, PostRepository $postRepository, PaginatorInterface $paginator): Response
public function indexAction(Request $request, PostRepository $postRepository, PaginatorInterface $paginator)
{
$postsPagination = $paginator->paginate(
$postRepository->createPublicFeedPostsQuery(),

View File

@ -1,20 +1,28 @@
<?php
declare(strict_types=1);
namespace App\Controller\Telegram;
namespace src\PointToolsBundle\Controller\Telegram;
use Psr\Log\LoggerInterface;
use src\PointToolsBundle\Service\Telegram\IncomingUpdateDispatcher;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{JsonResponse, Request, Response};
use unreal4u\Telegram\Types\Update;
use unreal4u\TelegramAPI\Telegram\Types\Update;
/**
* {@inheritdoc}
*/
class WebHookController extends AbstractController
{
public function __construct(
private readonly string $telegramToken,
private readonly bool $debugEnabled,
) {
/** @var string */
private $telegramToken;
/** @var bool */
private $debug;
public function __construct(string $telegramToken, bool $debug)
{
$this->telegramToken = $telegramToken;
$this->debug = $debug;
}
public function receiveUpdateAction(Request $request, string $token, IncomingUpdateDispatcher $updateDispatcher, LoggerInterface $logger): Response
@ -23,20 +31,21 @@ class WebHookController extends AbstractController
throw $this->createNotFoundException();
}
$content = \json_decode($request->getContent(), flags: JSON_THROW_ON_ERROR);
$content = json_decode($request->getContent(), true);
$update = new Update(
$content,
$logger
);
try {
$updateDispatcher->process($update);
} catch (\Exception $e) {
if ($this->debugEnabled) {
if ($this->debug) {
throw $e;
}
$logger->error('Telegram bot error', [
$logger->addError('Telegram bot error', [
'exception' => get_class($e),
'file' => $e->getFile(),
'line' => $e->getLine(),

View File

@ -1,24 +1,32 @@
<?php
declare(strict_types=1);
namespace App\Controller;
namespace src\PointToolsBundle\Controller;
use App\DTO\{TopUserDTO, DailyEventsDTO};
use Knp\Component\Pager\PaginatorInterface;
use Ob\HighchartsBundle\Highcharts\Highchart;
use App\Entity\User;
use App\Repository\{SubscriptionEventRepository, UserRenameEventRepository, UserRepository};
use src\PointToolsBundle\DTO\{TopUserDTO};
use src\PointToolsBundle\DTO\DailyEvents;
use src\PointToolsBundle\Entity\User;
use src\PointToolsBundle\Repository\UserRenameEventRepository;
use src\PointToolsBundle\Repository\UserRepository;
use src\PointToolsBundle\Repository\{SubscriptionEventRepository};
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Ob\HighchartsBundle\Highcharts\Highchart;
use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Translation\TranslatorInterface;
class UserController extends AbstractController
{
public function __construct(
private readonly TranslatorInterface $translator,
) {
/** @var TranslatorInterface */
private $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
/**
* @param string $login
*/
public function showAction(
Request $request,
string $login,
@ -60,16 +68,16 @@ class UserController extends AbstractController
}
/**
* @param DailyEventsDTO[] $eventsByDay
*@todo move to the service
* @todo move to the service
*
* @param DailyEvents[] $eventsByDay
*/
private function createEventsDynamicChart(array $eventsByDay = []): Highchart
{
$data = [];
foreach ($eventsByDay as $dailyEvents) {
$data[$dailyEvents->date->format('d.m')] = $dailyEvents->eventsCount;
$data[$dailyEvents->getDate()->format('d.m')] = $dailyEvents->getEventsCount();
}
return $this->createChart('eventschart', 'line', $data, 'Events by day', 'amount');
@ -85,7 +93,7 @@ class UserController extends AbstractController
$data = [];
foreach ($topUsers as $topUser) {
$data[$topUser->login] = $topUser->subscribersCount;
$data[$topUser->getLogin()] = $topUser->getSubscribersCount();
}
return $this->createChart('topchart', 'bar', $data, 'Top users', 'amount');

View File

@ -0,0 +1,8 @@
<?php
namespace src\PointToolsBundle\Exception\Factory\Blog;
class FactoryException extends \Exception
{
}

View File

@ -0,0 +1,10 @@
<?php
namespace src\PointToolsBundle\Exception\Factory\Blog;
use src\PointToolsBundle\Exception\Factory\Blog\FactoryException;
class InvalidDataException extends FactoryException
{
}

View File

@ -0,0 +1,26 @@
<?php
namespace src\PointToolsBundle\Exception\Factory\Blog;
use src\PointToolsBundle\DTO\Api\Post;
use src\PointToolsBundle\Exception\Factory\Blog\InvalidDataException;
class InvalidPostDataException extends InvalidDataException
{
/**
* @var Post
*/
private $post;
public function __construct($message = '', Post $post, $code = 0, \Exception $previous = null)
{
$this->post = $post;
parent::__construct($message, $code, $previous);
}
public function getPost(): Post
{
return $this->post;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace src\PointToolsBundle\Exception\Factory;
use src\PointToolsBundle\DTO\Api\User as UserDTO;
class InvalidUserDataException extends \Exception
{
/**
* @var UserDTO
*/
private $user;
public function __construct($message = "", UserDTO $user, $code = 0, \Exception $previous = null)
{
$this->user = $user;
parent::__construct($message, $code, $previous);
}
public function getUser(): UserDTO
{
return $this->user;
}
}

View File

@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Exception\Telegram;
namespace src\PointToolsBundle\Exception\Telegram;
class CommandProcessingException extends \Exception
{
}
}

View File

@ -1,14 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Form;
namespace src\PointToolsBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class UserSearchType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('login')

View File

@ -0,0 +1,9 @@
<?php
namespace src\PointToolsBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class SkobkinPointToolsBundle extends Bundle
{
}

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -81,7 +81,7 @@ class UpdateSubscriptionsCommand extends Command
$progress->start(count($usersForUpdate));
foreach ($usersForUpdate as $user) {
\usleep($this->pointApiDelay);
usleep($this->pointApiDelay);
$progress->advance();
$this->logger->info('Processing @'.$user->getLogin());

View File

@ -66,7 +66,7 @@ class UpdateUsersPrivacyCommand extends Command
$progress->start(count($usersForUpdate));
foreach ($usersForUpdate as $user) {
\usleep($this->pointApiDelay);
usleep($this->pointApiDelay);
$progress->advance();
$this->logger->info('Processing @'.$user->getLogin());

View File

@ -1,9 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Exception\Factory\Blog;
class FactoryException extends \Exception
{
}

View File

@ -1,9 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Exception\Factory\Blog;
class InvalidDataException extends FactoryException
{
}

View File

@ -1,17 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Exception\Factory\Blog;
use App\DTO\Api\Post;
class InvalidPostDataException extends InvalidDataException
{
public function __construct(
public readonly Post $post,
$code = 0,
\Exception $previous = null
) {
parent::__construct('Invalid post data', $code, $previous);
}
}

View File

@ -1,17 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Exception\Factory;
use App\DTO\Api\User as UserDTO;
class InvalidUserDataException extends \Exception
{
public function __construct(
public readonly UserDTO $user,
$code = 0,
\Exception $previous = null
) {
parent::__construct('Invalid user data', $code, $previous);
}
}

View File

@ -25,13 +25,13 @@ class UserFactory extends AbstractFactory
// @todo LOG
if (!$userData->isValid()) {
throw new InvalidUserDataException($userData);
throw new InvalidUserDataException('Invalid user data', $userData);
}
/** @var User $user */
if (null === ($user = $this->userRepository->find($userData->getId()))) {
$user = new User(
(int) $userData->getId(),
$userData->getId(),
\DateTime::createFromFormat('Y-m-d_H:i:s', $userData->getCreated()) ?: new \DateTime()
);
$this->userRepository->add($user);

View File

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Repository;
use App\DTO\DailyEventsDTO;
use App\Entity\SubscriptionEvent;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
@ -102,14 +101,14 @@ class SubscriptionEventRepository extends ServiceEntityRepository
return $qb->getQuery()->getResult();
}
/** @return DailyEventsDTO[] */
/** @return SubscriptionEvent[] */
public function getLastEventsByDay(int $days = 30): array
{
$qb = $this->createQueryBuilder('se');
$rows = $qb
->select([
'NEW App\DTO\DailyEventsDTO(DAY(se.date), COUNT(se))',
'NEW Skobkin\Bundle\PointToolsBundle\DTO\DailyEvents(DAY(se.date), COUNT(se))',
'DAY(se.date) as day',
])
->groupBy('day')

View File

@ -1,10 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Repository;
use App\DTO\TopUserDTO;
use App\Entity\Subscription;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@ -115,11 +114,11 @@ class UserRepository extends ServiceEntityRepository
*/
public function getTopUsers(int $limit = 30): array
{
$qb = $this->getEntityManager()->getRepository(Subscription::class)->createQueryBuilder('s');
$qb = $this->getEntityManager()->getRepository('SkobkinPointToolsBundle:Subscription')->createQueryBuilder('s');
$rows = $qb
->select([
'NEW App\DTO\TopUserDTO(a.login, COUNT(s.subscriber))',
'NEW Skobkin\Bundle\PointToolsBundle\DTO\TopUserDTO(a.login, COUNT(s.subscriber))',
'COUNT(s.subscriber) as subscribers_count'
])
->innerJoin('s.author', 'a')

View File

@ -47,9 +47,6 @@
"config/packages/jms_serializer.yaml"
]
},
"knplabs/knp-paginator-bundle": {
"version": "v6.2.0"
},
"phpunit/phpunit": {
"version": "9.6",
"recipe": {