diff --git a/src/Controller/ActivityController.php b/src/Controller/ActivityController.php index a0da1ab..0749b06 100644 --- a/src/Controller/ActivityController.php +++ b/src/Controller/ActivityController.php @@ -15,7 +15,7 @@ use App\Service\TorrentService; class ActivityController extends AbstractController { - public function template( + public function event( $activity, ActivityService $activityService, UserService $userService, diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 665efc0..cf7078f 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -57,7 +57,7 @@ class UserController extends AbstractController return $this->render( 'default/user/dashboard.html.twig', [ - 'activities' => $activityService->findLastEvents( + 'activities' => $activityService->findLastActivities( $user->getEvents() ) ] @@ -254,8 +254,12 @@ class UserController extends AbstractController $userTarget->getId() ) ], + 'activities' => $activityService->findLastActivitiesByUserId( + $userTarget->getId(), + $userTarget->getEvents() + ) ], - 'events' => $activityService->getEventsTree() + 'events' => $activityService->getEventsTree(), ] ); } diff --git a/src/Service/ActivityService.php b/src/Service/ActivityService.php index 1b11d8a..029d28c 100644 --- a/src/Service/ActivityService.php +++ b/src/Service/ActivityService.php @@ -360,7 +360,7 @@ class ActivityService return $events; } - public function findLastEvents( + public function findLastActivities( array $whitelist ): array { @@ -376,6 +376,24 @@ class ActivityService ); } + public function findLastActivitiesByUserId( + int $userId, + array $whitelist + ): array + { + return $this->entityManagerInterface + ->getRepository(Activity::class) + ->findBy( + [ + 'userId' => $userId, + 'event' => $whitelist + ], + [ + 'id' => 'DESC' + ] + ); + } + // User public function addEventUserAdd( int $userId, diff --git a/templates/default/user/dashboard.html.twig b/templates/default/user/dashboard.html.twig index 189e3b1..655b728 100644 --- a/templates/default/user/dashboard.html.twig +++ b/templates/default/user/dashboard.html.twig @@ -4,7 +4,7 @@ {% for activity in activities %}