[ongeki] Fix event ranking query incompatibility with MySQL/MariaDB

This commit is contained in:
Mikira Sora
2023-03-24 17:51:27 +00:00
committed by Dom Eori
parent 35f0c000bf
commit 447ddd99b0
4 changed files with 47 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ public interface UserEventPointRepository extends JpaRepository<UserEventPoint,
@Transactional
void deleteByUser(UserData user);
@Query(value = "SELECT rank from (SELECT user_id , DENSE_RANK() OVER (ORDER BY point DESC) as rank from ongeki_user_event_point where event_id = :eventId) where user_id == :userId limit 1", nativeQuery = true)
//@Query(value = "SELECT rank from (SELECT user_id , DENSE_RANK() OVER (ORDER BY point DESC) as rank from ongeki_user_event_point where event_id = :eventId) where user_id == :userId limit 1", nativeQuery = true)
@Query("SELECT COUNT(u)+1 FROM OngekiUserEventPoint u WHERE u.eventId = :eventId AND u.point > (SELECT u2.point FROM OngekiUserEventPoint u2 WHERE u2.user.id = :userId AND u2.eventId = :eventId)")
int calculateRankByUserAndEventId(long userId, int eventId);
}