Skip to content

Commit 3d2c557

Browse files
authored
Add new league columns (#580)
* Add new league columns * Bump league service version
1 parent fadcbee commit 3d2c557

6 files changed

Lines changed: 36 additions & 16 deletions

File tree

src/inttest/java/com/faforever/api/config/LeagueDbTestContainers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@Configuration
2121
public class LeagueDbTestContainers {
2222
private static final MariaDBContainer<?> leagueServiceDBContainer = new MariaDBContainer<>("mariadb:10.6");
23-
private static final GenericContainer<?> leagueServiceContainer = new GenericContainer<>("faforever/faf-league-service:1.0.0");
23+
private static final GenericContainer<?> leagueServiceContainer = new GenericContainer<>("faforever/faf-league-service:1.1.0");
2424
private static final Network sharedNetwork = Network.newNetwork();
2525

2626
@Bean

src/inttest/java/com/faforever/api/league/LeagueSeasonElideTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import static com.faforever.api.data.JsonApiMediaType.JSON_API_MEDIA_TYPE;
1212
import static org.hamcrest.Matchers.hasSize;
13+
import static org.hamcrest.Matchers.is;
1314
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
1415
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
1516
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
@@ -35,7 +36,11 @@ void anyOneCanReadSpecificLeagueSeason() throws Exception {
3536
mockMvc.perform(
3637
get("/data/leagueSeason/1")
3738
)
38-
.andExpect(status().isOk());
39+
.andExpect(status().isOk())
40+
.andExpect(jsonPath("$.data.attributes.placementGames", is(10)))
41+
.andExpect(jsonPath("$.data.attributes.placementGamesReturningPlayer", is(3)))
42+
.andExpect(jsonPath("$.data.attributes.seasonNumber", is(1)))
43+
.andExpect(jsonPath("$.data.attributes.nameKey", is("season1")));
3944
}
4045

4146
@Test

src/inttest/java/com/faforever/api/league/LeagueSeasonScoreElideTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import static com.faforever.api.data.JsonApiMediaType.JSON_API_MEDIA_TYPE;
1212
import static org.hamcrest.Matchers.hasSize;
13+
import static org.hamcrest.Matchers.is;
1314
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
1415
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
1516
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
@@ -44,7 +45,11 @@ void anyOneCanReadSpecificLeagueSeasonScore() throws Exception {
4445
mockMvc.perform(
4546
get("/data/leagueSeasonScore/1")
4647
)
47-
.andExpect(status().isOk());
48+
.andExpect(status().isOk())
49+
.andExpect(jsonPath("$.data.attributes.loginId", is(1)))
50+
.andExpect(jsonPath("$.data.attributes.score", is(10)))
51+
.andExpect(jsonPath("$.data.attributes.gameCount", is(10)))
52+
.andExpect(jsonPath("$.data.attributes.returningPlayer", is(false)));
4853
}
4954

5055
@Test

src/inttest/resources/sql/league/prepLeagueData.sql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ VALUES (1, 'league1', 'league_name_1', 'league_description_1',
66
(2, 'league2', 'league_name_2', 'league_description_2',
77
'https://example2.com/', 'https://example2.com/medium/', 'https://example2.com/small/');
88

9-
INSERT INTO league_season (id, league_id, leaderboard_id, placement_games, season_number,
10-
name_key, start_date, end_date)
11-
VALUES (1, 1, 1, 10, 1, 'season1', NOW(), DATE_ADD(NOW(), INTERVAL 1 MONTH)),
12-
(2, 2, 2, 10, 2, 'season2', DATE_SUB(NOW(), INTERVAL 1 MONTH), DATE_SUB(NOW(), INTERVAL 1 DAY));
9+
INSERT INTO league_season (id, league_id, leaderboard_id, placement_games, placement_games_returning_player,
10+
season_number, name_key, start_date, end_date)
11+
VALUES (1, 1, 1, 10, 3, 1, 'season1', NOW(), DATE_ADD(NOW(), INTERVAL 1 MONTH)),
12+
(2, 2, 2, 10, 3, 2, 'season2', DATE_SUB(NOW(), INTERVAL 1 MONTH), DATE_SUB(NOW(), INTERVAL 1 DAY));
1313

1414
INSERT INTO league_season_division (id, league_season_id, division_index, name_key, description_key)
1515
VALUES (1, 1, 1, 'division_name_1', 'division_description_1'),
@@ -24,15 +24,15 @@ VALUES (1, 1, 1, 'subdivision_name_1', 'subdivision_description_1', 0.0, 1000.0,
2424
(3, 2, 3, 'subdivision_name_3', 'subdivision_description_3', 0.0, 500.0, 50),
2525
(4, 2, 4, 'subdivision_name_4', 'subdivision_description_4', 500.0, 1000.0, 550);
2626

27-
INSERT INTO league_season_score (id, league_season_id, subdivision_id, login_id, score, game_count)
28-
VALUES (1, 1, 1, 1, 10, 10),
29-
(2, 1, 1, 2, 11, 10),
30-
(3, 1, 1, 3, 12, 10),
31-
(4, 1, 1, 4, 13, 10),
32-
(5, 1, 2, 5, 20, 20),
33-
(6, 1, 2, 6, 21, 20),
34-
(7, 1, 2, 7, 22, 20),
35-
(8, 1, 2, 8, 23, 20);
27+
INSERT INTO league_season_score (id, league_season_id, subdivision_id, login_id, score, game_count, returning_player)
28+
VALUES (1, 1, 1, 1, 10, 10, FALSE),
29+
(2, 1, 1, 2, 11, 10, FALSE),
30+
(3, 1, 1, 3, 12, 10, FALSE),
31+
(4, 1, 1, 4, 13, 10, FALSE),
32+
(5, 1, 2, 5, 20, 20, FALSE),
33+
(6, 1, 2, 6, 21, 20, FALSE),
34+
(7, 1, 2, 7, 22, 20, FALSE),
35+
(8, 1, 2, 8, 23, 20, FALSE);
3636

3737
INSERT INTO league_score_journal (id, login_id, league_season_id, subdivision_id_before, subdivision_id_after,
3838
score_before, score_after, game_count)

src/main/java/com/faforever/api/league/domain/LeagueSeason.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class LeagueSeason {
2424
private League league;
2525
private Leaderboard leaderboard;
2626
private Integer placementGames;
27+
private Integer placementGamesReturningPlayer;
2728
private Integer seasonNumber;
2829
private String nameKey;
2930
private OffsetDateTime startDate;
@@ -53,6 +54,9 @@ public Integer getPlacementGames() {
5354
return placementGames;
5455
}
5556

57+
@Column(name = "placement_games_returning_player")
58+
public Integer getPlacementGamesReturningPlayer() {return placementGamesReturningPlayer;}
59+
5660
@Column(name = "season_number")
5761
public Integer getSeasonNumber() {
5862
return seasonNumber;

src/main/java/com/faforever/api/league/domain/LeagueSeasonScore.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class LeagueSeasonScore {
2525
private LeagueSeasonDivisionSubdivision leagueSeasonDivisionSubdivision;
2626
private Integer score;
2727
private Integer gameCount;
28+
private Boolean returningPlayer;
2829

2930
@Id
3031
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -59,4 +60,9 @@ public Integer getScore() {
5960
public Integer getGameCount() {
6061
return gameCount;
6162
}
63+
64+
@Column(name = "returning_player")
65+
public Boolean getReturningPlayer() {
66+
return returningPlayer;
67+
}
6268
}

0 commit comments

Comments
 (0)