diff --git a/src/Module/Database/View/DiscovererRating/DiscovererRanking.php b/src/Module/Database/View/DiscovererRating/DiscovererRanking.php index de52caaff..5084c0bf5 100644 --- a/src/Module/Database/View/DiscovererRating/DiscovererRanking.php +++ b/src/Module/Database/View/DiscovererRating/DiscovererRanking.php @@ -44,7 +44,11 @@ public function handle(GameControllerInterface $game): void $game->setTemplateVar( 'DISCOVERER_LIST', array_map( - fn (array $data): DatabaseTopListWithPoints => $this->databaseUiFactory->createDatabaseTopListWithPoints($data['user_id'], (string) $data['points']), + fn (array $data): DatabaseTopListWithPoints => $this->databaseUiFactory->createDatabaseTopListWithPoints( + $data['user_id'], + (string) $data['points'], + $data['timestamp'], + ), $this->databaseUserRepository->getTopList() ) ); diff --git a/src/Orm/Repository/DatabaseUserRepository.php b/src/Orm/Repository/DatabaseUserRepository.php index 46a8906ee..a83020083 100644 --- a/src/Orm/Repository/DatabaseUserRepository.php +++ b/src/Orm/Repository/DatabaseUserRepository.php @@ -62,15 +62,22 @@ public function getTopList(): array $rsm = new ResultSetMapping(); $rsm->addScalarResult('user_id', 'user_id', 'integer'); $rsm->addScalarResult('points', 'points', 'integer'); + $rsm->addScalarResult('timestamp', 'timestamp', 'integer'); return $this->getEntityManager() ->createNativeQuery( - 'SELECT dbu.user_id, SUM(dbc.points) as points FROM stu_database_user dbu LEFT JOIN - stu_database_entrys dbe ON dbe.id = dbu.database_id LEFT JOIN stu_database_categories dbc ON - dbc.id = dbe.category_id + 'SELECT dbu.user_id, SUM(dbc.points) AS points, + (SELECT MAX(du.date) + FROM stu_database_user du + WHERE du.user_id = dbu.user_id) AS timestamp + FROM stu_database_user dbu + LEFT JOIN stu_database_entrys dbe + ON dbe.id = dbu.database_id + LEFT JOIN stu_database_categories dbc + ON dbc.id = dbe.category_id WHERE dbu.user_id > :firstUserId GROUP BY dbu.user_id - ORDER BY points DESC + ORDER BY points DESC, timestamp ASC LIMIT 10', $rsm ) diff --git a/src/Orm/Repository/DatabaseUserRepositoryInterface.php b/src/Orm/Repository/DatabaseUserRepositoryInterface.php index 46ebfb663..1c57737d8 100644 --- a/src/Orm/Repository/DatabaseUserRepositoryInterface.php +++ b/src/Orm/Repository/DatabaseUserRepositoryInterface.php @@ -22,7 +22,7 @@ public function prototype(): DatabaseUserInterface; public function save(DatabaseUserInterface $entry): void; /** - * @return array + * @return array */ public function getTopList(): array; diff --git a/src/html/database.xhtml b/src/html/database.xhtml index 7549ec62e..6add08487 100755 --- a/src/html/database.xhtml +++ b/src/html/database.xhtml @@ -16,7 +16,7 @@ tal:define="USER entry/getUser" />
USER
-
+
Punkte: AMOUNT