forked from Cookies_Github_mirror/AquaDX
[ongeki] Add support for actual ingame event ranking
This commit is contained in:
@@ -3,6 +3,7 @@ package icu.samnyan.aqua.sega.ongeki.dao.userdata;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserEventPoint;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -21,4 +22,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)
|
||||
int calculateRankByUserAndEventId(long userId, int eventId);
|
||||
}
|
||||
|
||||
@@ -40,17 +40,15 @@ public class GetUserEventRankingHandler implements BaseHandler {
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.0"));
|
||||
|
||||
// TODO: query ranking from database
|
||||
List<UserEventPoint> eventPointList = userEventPointRepository.findByUser_Card_ExtId(userId);
|
||||
List<UserEventRankingItem> rankingItemList = new LinkedList<>();
|
||||
eventPointList.forEach(x -> rankingItemList.add(new UserEventRankingItem(
|
||||
x.getEventId(),
|
||||
1, // Type 1 is latest ranking
|
||||
time,
|
||||
1,
|
||||
userEventPointRepository.calculateRankByUserAndEventId(x.getUser().getId(), x.getEventId()),
|
||||
x.getPoint()
|
||||
)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user