Skip to content
Snippets Groups Projects
Commit ab6d6bdf authored by Jozef Bugos's avatar Jozef Bugos
Browse files

changing url, updating ci/cd

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