Skip to content
Snippets Groups Projects
Commit dd4c7471 authored by Jozef Bugoš's avatar Jozef Bugoš
Browse files

Merge branch 'rc' into 'master'

Rc

See merge request !1
parents e32d4e0a 9609177a
No related branches found
No related tags found
1 merge request!1Rc
Pipeline #34057 passed
...@@ -4,7 +4,7 @@ services: ...@@ -4,7 +4,7 @@ services:
variables: variables:
DOCKER_DRIVER: overlay DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci # SPRING_PROFILES_ACTIVE: gitlab-ci
USER_GITLAB: bugosjoz USER_GITLAB: bugosjoz
APP_NAME: lol-statistics APP_NAME: lol-statistics
REPO: lol-statis REPO: lol-statis
...@@ -12,15 +12,27 @@ variables: ...@@ -12,15 +12,27 @@ variables:
stages: stages:
- build - build
- test - test
# - docker - docker
maven-build: maven-build-master:
image: maven:3.6.3-jdk-11 image: maven:3.6.3-jdk-11
stage: build stage: build
script: "mvn clean package -B" script: "mvn clean package -P prod"
artifacts: artifacts:
paths: paths:
- target/*.jar - target/*.jar
only:
- master
maven-build-dev:
image: maven:3.6.3-jdk-11
stage: build
script: "mvn clean package -P dev"
artifacts:
paths:
- target/*.jar
except:
- master
maven-test: maven-test:
image: maven:3.6.3-jdk-11 image: maven:3.6.3-jdk-11
...@@ -30,9 +42,11 @@ maven-test: ...@@ -30,9 +42,11 @@ maven-test:
paths: paths:
- target/*.jar - target/*.jar
#docker-build: docker-build:
# stage: docker stage: docker
# script: script:
# - sudo docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - sudo docker build -t bugosjoz/lol-statistics .
# - sudo docker build -t registry.gitlab.com/bugosjoz/lol-statistics . - sudo docker login -u "$DOCKER_LOGIN" -p "$DOCKER_PASSWORD"
# - sudo docker push registry.gitlab.com/bugosjoz/lol-statistics - sudo docker push bugosjoz/lol-statistics:latest
only:
- master
FROM openjdk:13-alpine FROM openjdk:13-alpine
VOLUME /tmp VOLUME /tmp
ADD /target/*.jar lol-statistics-0.0.1-SNAPSHOT.jar ADD /target/*.jar lol-statistics-0.0.1-SNAPSHOT.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/lol-statistics-0.0.1-SNAPSHOT.jar"] ENTRYPOINT ["java","-jar","/lol-statistics-0.0.1-SNAPSHOT.jar"]
\ No newline at end of file
...@@ -17,7 +17,7 @@ import springfox.documentation.spring.web.plugins.Docket; ...@@ -17,7 +17,7 @@ import springfox.documentation.spring.web.plugins.Docket;
import java.util.List; import java.util.List;
@SpringBootApplication @SpringBootApplication
//@EnableDiscoveryClient @EnableDiscoveryClient
public class DemoApplication { public class DemoApplication {
@Bean @Bean
...@@ -38,9 +38,9 @@ class ServiceInstanceRestController { ...@@ -38,9 +38,9 @@ class ServiceInstanceRestController {
@Autowired @Autowired
private DiscoveryClient discoveryClient; private DiscoveryClient discoveryClient;
@RequestMapping("/service-instances/{applicationName}") // @RequestMapping("/service-instances/{applicationName}")
public List<ServiceInstance> serviceInstancesByApplicationName( // public List<ServiceInstance> serviceInstancesByApplicationName(
@PathVariable String applicationName) { // @PathVariable String applicationName) {
return this.discoveryClient.getInstances(applicationName); // return this.discoveryClient.getInstances(applicationName);
} // }
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
...@@ -35,8 +36,8 @@ public class RiotController { ...@@ -35,8 +36,8 @@ public class RiotController {
* @param username username of the wanted player * @param username username of the wanted player
* @return OK(200) status if user exist, UNPROCESSABLE_ENTITY(422) otherwise * @return OK(200) status if user exist, UNPROCESSABLE_ENTITY(422) otherwise
*/ */
@GetMapping("/exists") @GetMapping(value = "/server/{server}/user/{user}")
public ResponseEntity exists(@RequestParam String server, @RequestParam String username) { public ResponseEntity exists(@PathVariable("server") String server, @PathVariable("user") String username) {
return !getAccountIdIfExists(server, username).equals("") ? return !getAccountIdIfExists(server, username).equals("") ?
new ResponseEntity(HttpStatus.OK) new ResponseEntity(HttpStatus.OK)
: :
...@@ -53,8 +54,8 @@ public class RiotController { ...@@ -53,8 +54,8 @@ public class RiotController {
* @param username username of the wanted player * @param username username of the wanted player
* @return List of match stats for X last games played of specified user * @return List of match stats for X last games played of specified user
*/ */
@GetMapping("/stats") @GetMapping("/server/{server}/user/{user}/statistics")
public ResponseEntity<MatchStats[]> getStatsForMatches(@RequestParam String server, @RequestParam String username) { public ResponseEntity<MatchStats[]> getStatsForMatches(@PathVariable("server") String server, @PathVariable("user") String username) {
log.info("Requesting statistics for account with username '" + username + "' on '" + server + "' server"); log.info("Requesting statistics for account with username '" + username + "' on '" + server + "' server");
String userId = getAccountIdIfExists(server, username); String userId = getAccountIdIfExists(server, username);
if(userId.equals("")) { if(userId.equals("")) {
...@@ -93,7 +94,7 @@ public class RiotController { ...@@ -93,7 +94,7 @@ public class RiotController {
String id = riotService.getAcccountId(server, username); String id = riotService.getAcccountId(server, username);
log.info("Account with username '" + username + "' exists on '" + server + "' server"); log.info("Account with username '" + username + "' exists on '" + server + "' server");
return id; return id;
} catch (HttpClientErrorException ex) { } catch (Exception ex ) {
log.warn("Account with username '" + username + "' does not exist on '" + server + "' server"); log.warn("Account with username '" + username + "' does not exist on '" + server + "' server");
return ""; return "";
......
...@@ -14,7 +14,7 @@ public interface IRiotService { ...@@ -14,7 +14,7 @@ public interface IRiotService {
* *
* @param server tag of the wanted server * @param server tag of the wanted server
* @param username username of the wanted player * @param username username of the wanted player
* @return account id of the given userr * @return account id of the given user
*/ */
String getAcccountId(String server, String username); String getAcccountId(String server, String username);
...@@ -23,7 +23,7 @@ public interface IRiotService { ...@@ -23,7 +23,7 @@ public interface IRiotService {
* *
* @param server tag of the wanted server * @param server tag of the wanted server
* @param id account id of the wanted player * @param id account id of the wanted player
* @return matcch history * @return match history
*/ */
MatchesBean getMatchHistory(String server, String id); MatchesBean getMatchHistory(String server, String id);
...@@ -32,7 +32,7 @@ public interface IRiotService { ...@@ -32,7 +32,7 @@ public interface IRiotService {
* *
* @param server tag of the wanted server * @param server tag of the wanted server
* @param id account id of the wanted player * @param id account id of the wanted player
* @param matches number of matchces to consider * @param matches number of matches to consider
* @return match history * @return match history
*/ */
MatchesBean getMatchHistory(String server, String id, int matches); MatchesBean getMatchHistory(String server, String id, int matches);
...@@ -42,7 +42,7 @@ public interface IRiotService { ...@@ -42,7 +42,7 @@ public interface IRiotService {
* *
* @param server tag of the wanted server * @param server tag of the wanted server
* @param id account id of the wanted player * @param id account id of the wanted player
* @param matches number of matchces to consider * @param matches number of matches to consider
* @param timestamp date and time of the match played by the given player * @param timestamp date and time of the match played by the given player
* @return match history * @return match history
*/ */
......
...@@ -22,7 +22,7 @@ public class RiotService implements IRiotService { ...@@ -22,7 +22,7 @@ public class RiotService implements IRiotService {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
static int counter = 0; // static int counter = 0;
private final long MILISECONDS_IN_WEEK = 604800000; private final long MILISECONDS_IN_WEEK = 604800000;
private final long MILISECONDS_IN_THREE_MINUTES = 180000; private final long MILISECONDS_IN_THREE_MINUTES = 180000;
...@@ -36,7 +36,7 @@ public class RiotService implements IRiotService { ...@@ -36,7 +36,7 @@ public class RiotService implements IRiotService {
.queryParam("api_key", key) .queryParam("api_key", key)
.build().toUri(); .build().toUri();
log.info("Getting account id for username '" + username + "' on server " + server); log.info("Getting account id for username '" + username + "' on server " + server);
log.info("" + ++counter); // log.info("" + ++counter);
UserBean result = restTemplate.getForObject(uriAccount, UserBean.class); UserBean result = restTemplate.getForObject(uriAccount, UserBean.class);
return result.getAccountId(); return result.getAccountId();
} }
...@@ -78,7 +78,7 @@ public class RiotService implements IRiotService { ...@@ -78,7 +78,7 @@ public class RiotService implements IRiotService {
+ (beginTime >= 0 ? " from week before " + timestamp : "") + (beginTime >= 0 ? " from week before " + timestamp : "")
); );
try { try {
log.info("" + ++counter); // log.info("" + ++counter);
return restTemplate.getForObject(uriHistory, MatchesBean.class); return restTemplate.getForObject(uriHistory, MatchesBean.class);
} catch (HttpClientErrorException ex) { } catch (HttpClientErrorException ex) {
log.warn("No matches in week before " + timestamp + ". Returning empty list."); log.warn("No matches in week before " + timestamp + ". Returning empty list.");
...@@ -95,7 +95,7 @@ public class RiotService implements IRiotService { ...@@ -95,7 +95,7 @@ public class RiotService implements IRiotService {
.build().toUri(); .build().toUri();
log.info("Getting match detail for match with id '" + id + "' on server " + server); log.info("Getting match detail for match with id '" + id + "' on server " + server);
log.info("" + ++counter); // log.info("" + ++counter);
return restTemplate.getForObject(uriHistory, MatchDetailBean.class); return restTemplate.getForObject(uriHistory, MatchDetailBean.class);
} }
......
...@@ -90,7 +90,7 @@ class RiotControllerIntegrationTest { ...@@ -90,7 +90,7 @@ class RiotControllerIntegrationTest {
.accept(MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON_VALUE)
.when() .when()
.get("/exists?server=" + server + "&username=" + username) .get("/server/" + server + "/user/" + username)
// verify // verify
.then() .then()
.log() .log()
...@@ -121,7 +121,7 @@ class RiotControllerIntegrationTest { ...@@ -121,7 +121,7 @@ class RiotControllerIntegrationTest {
.accept(MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON_VALUE)
.when() .when()
.get("/exists?server=" + server + "&username=" + username) .get("/server/" + server + "/user/" + username)
// verify // verify
.then() .then()
.log() .log()
...@@ -201,7 +201,7 @@ class RiotControllerIntegrationTest { ...@@ -201,7 +201,7 @@ class RiotControllerIntegrationTest {
.accept(MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON_VALUE)
.when() .when()
.get("/stats?server=" + server + "&username=" + username) .get("/server/" + server + "/user/" + username + "/statistics")
// verify // verify
.then() .then()
.log() .log()
...@@ -235,7 +235,7 @@ class RiotControllerIntegrationTest { ...@@ -235,7 +235,7 @@ class RiotControllerIntegrationTest {
.accept(MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON_VALUE)
.when() .when()
.get("/stats?server=" + server + "&username=" + username) .get("/server/" + server + "/user/" + username + "/statistics")
// verify // verify
.then() .then()
.log() .log()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment