Last user subscribers events query optimized.
This commit is contained in:
parent
57cedf5417
commit
c5f63d86cb
|
@ -30,7 +30,7 @@ class UserController extends Controller
|
|||
return $this->render('SkobkinPointToolsBundle:User:show.html.twig', [
|
||||
'user' => $user,
|
||||
'subscribers' => $em->getRepository('SkobkinPointToolsBundle:User')->findUserSubscribersById($user->getId()),
|
||||
'log' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getUserLastSubscriptionEventsById($user, 10),
|
||||
'log' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getUserLastSubscribersEventsById($user, 10),
|
||||
'avatar_url' => $userApi->getAvatarUrl($user, UserApi::AVATAR_SIZE_LARGE),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class SubscriptionEventRepository extends EntityRepository
|
|||
* @param integer $limit
|
||||
* @return SubscriptionEvent[]
|
||||
*/
|
||||
public function getUserLastSubscriptionEventsById(User $user, $limit)
|
||||
public function getUserLastSubscribersEventsById(User $user, $limit)
|
||||
{
|
||||
if (!is_int($limit)) {
|
||||
throw new \InvalidArgumentException('$limit must be an integer');
|
||||
|
@ -38,7 +38,8 @@ class SubscriptionEventRepository extends EntityRepository
|
|||
$qb = $this->createQueryBuilder('se');
|
||||
|
||||
return $qb
|
||||
->select()
|
||||
->select(['se', 's'])
|
||||
->join('se.subscriber', 's')
|
||||
->where('se.author = :author')
|
||||
->orderBy('se.date', 'desc')
|
||||
->setMaxResults($limit)
|
||||
|
|
Loading…
Reference in a new issue