mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-11 17:07:27 +08:00
Merge branch 'master' into 'master'
[ongeki,general] Fix bug about calculateRankByUserAndEventId() and add test config file for mysql See merge request domeori/aqua!21
This commit is contained in:
@@ -23,6 +23,7 @@ public interface UserEventPointRepository extends JpaRepository<UserEventPoint,
|
|||||||
@Transactional
|
@Transactional
|
||||||
void deleteByUser(UserData user);
|
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);
|
int calculateRankByUserAndEventId(long userId, int eventId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,19 +181,28 @@ class OngekiRepositoryTest {
|
|||||||
var u1 = getNewRandomValidUser();
|
var u1 = getNewRandomValidUser();
|
||||||
var u2 = getNewRandomValidUser();
|
var u2 = getNewRandomValidUser();
|
||||||
var u3 = getNewRandomValidUser();
|
var u3 = getNewRandomValidUser();
|
||||||
|
var u4 = getNewRandomValidUser();
|
||||||
|
|
||||||
final var eventId = 2857;
|
final var eventId = 2857;
|
||||||
|
final var eventId2 = 2858;
|
||||||
|
|
||||||
userEventPointRepository.saveAll(List.of(
|
userEventPointRepository.saveAll(List.of(
|
||||||
getEventPoint(u1, eventId, 500),
|
getEventPoint(u3, eventId, 2857),
|
||||||
getEventPoint(u2, eventId, 600),
|
getEventPoint(u2, eventId, 600),
|
||||||
getEventPoint(u3, eventId, 2857)
|
getEventPoint(u4, eventId, 600),
|
||||||
|
getEventPoint(u1, eventId, 500),
|
||||||
|
|
||||||
|
getEventPoint(u3, eventId2, 2857),
|
||||||
|
getEventPoint(u4, eventId2, 600),
|
||||||
|
getEventPoint(u2, eventId2, 25)
|
||||||
));
|
));
|
||||||
|
|
||||||
var eventPointData = userEventPointRepository.findByUser_Card_ExtId(u1.getCard().getExtId()).get(0);
|
assertThat(calculateEventPointRank(u1, eventId)).isEqualTo(4);
|
||||||
|
assertThat(calculateEventPointRank(u4, eventId)).isEqualTo(2);
|
||||||
|
assertThat(calculateEventPointRank(u3, eventId)).isEqualTo(1);
|
||||||
|
|
||||||
var rank = userEventPointRepository.calculateRankByUserAndEventId(eventPointData.getUser().getId(), eventPointData.getEventId());
|
assertThat(calculateEventPointRank(u4, eventId2)).isEqualTo(2);
|
||||||
assertThat(rank).isEqualTo(3);
|
assertThat(calculateEventPointRank(u2, eventId2)).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -418,6 +427,12 @@ class OngekiRepositoryTest {
|
|||||||
return new UserCharacter(-1, u, characterId, 0, 0, 10, 1, 1, 1, "2020", false);
|
return new UserCharacter(-1, u, characterId, 0, 0, 10, 1, 1, 1, "2020", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int calculateEventPointRank(UserData user, int eventId) {
|
||||||
|
var eventPointData = userEventPointRepository.findByUserAndEventId(user, eventId).get();
|
||||||
|
var rank = userEventPointRepository.calculateRankByUserAndEventId(eventPointData.getUser().getId(), eventPointData.getEventId());
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
private UserDeck getDeck(UserData u, Integer deckId) {
|
private UserDeck getDeck(UserData u, Integer deckId) {
|
||||||
return new UserDeck(-1, u, deckId, 1, 1, 1);
|
return new UserDeck(-1, u, deckId, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
22
src/test/resources/application-testMariadb.properties
Normal file
22
src/test/resources/application-testMariadb.properties
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# For testing
|
||||||
|
## AimeDb server setting
|
||||||
|
aimedb.server.enable=true
|
||||||
|
aimedb.server.port=22345
|
||||||
|
allnet.server.host=localhost
|
||||||
|
allnet.server.port=80
|
||||||
|
aimedb.server.address=127.0.0.1
|
||||||
|
billing.server.enable=true
|
||||||
|
billing.server.port=8443
|
||||||
|
## Http Server Port
|
||||||
|
server.port=80
|
||||||
|
spring.flyway.locations=classpath:db/migration/mariadb
|
||||||
|
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
|
||||||
|
spring.datasource.username=aqua_test
|
||||||
|
spring.datasource.password=aqua_test
|
||||||
|
spring.datasource.url=jdbc:mariadb://localhost:3306/aqua_test?useSSL=false
|
||||||
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB10Dialect
|
||||||
|
|
||||||
|
# if you got any exception like while application booting:
|
||||||
|
# "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [id] in table [chusan_avatar]; found [int (Types#INTEGER)], but expecting [bigint (Types#BIGINT)]"
|
||||||
|
# just comment this property and try again.
|
||||||
|
# spring.jpa.hibernate.ddl-auto=validate
|
||||||
@@ -10,9 +10,8 @@ billing.server.port=8443
|
|||||||
## Http Server Port
|
## Http Server Port
|
||||||
server.port=80
|
server.port=80
|
||||||
spring.flyway.locations=classpath:db/migration/mysql
|
spring.flyway.locations=classpath:db/migration/mysql
|
||||||
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.username=aqua_test
|
spring.datasource.username=aqua_test
|
||||||
spring.datasource.password=aqua_test
|
spring.datasource.password=aqua_test
|
||||||
spring.datasource.url=jdbc:mariadb://localhost:3306/aqua_test?useSSL=false
|
spring.datasource.url=jdbc:mysql://localhost:13306/aqua_test?useSSL=false&allowPublicKeyRetrieval=true
|
||||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB10Dialect
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||||
spring.jpa.hibernate.ddl-auto=validate
|
|
||||||
|
|||||||
Reference in New Issue
Block a user