add last user activity on profile page

This commit is contained in:
ghost 2023-10-11 23:03:45 +03:00
parent 9c9dc5b5a4
commit cc6c68957c
5 changed files with 43 additions and 5 deletions

View file

@ -15,7 +15,7 @@ use App\Service\TorrentService;
class ActivityController extends AbstractController
{
public function template(
public function event(
$activity,
ActivityService $activityService,
UserService $userService,

View file

@ -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(),
]
);
}

View file

@ -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,