Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcuseMi committed Aug 26, 2016
1 parent 1677acf commit b547255
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 52 deletions.
22 changes: 17 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down Expand Up @@ -109,6 +104,23 @@
<resource>row-table.css</resource>
</transformer>
</transformers>
<filters>
<filter>
<!--
Exclude files that sign a jar
(one or multiple of the dependencies).
One may not repack a signed jar without
this, or you will get a
SecurityException at program start.
-->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.INF</exclude> <!-- This one may not be required -->
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface StatisticsRepository {
Statistics find(String playerId, GamingSystem gamingSystem);

default Map<PlayerIdentifier,Statistics> find(List<PlayerIdentifier> playerIdentifiers) throws Exception {
Map<PlayerIdentifier,Statistics> map = new HashMap<>();
playerIdentifiers.forEach(p->map.put(p, find(p.getPlayerId(), p.getGamingSystem())));
playerIdentifiers.parallelStream().forEachOrdered(p->map.put(p, find(p.getPlayerId(), p.getGamingSystem())));
return map;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.excuseme.rocketleaguelivestats.repository.rocketleague;


import com.excuseme.rocketleaguelivestats.model.*;
import com.excuseme.rocketleaguelivestats.model.GamingSystem;
import com.excuseme.rocketleaguelivestats.model.Rank;
import com.excuseme.rocketleaguelivestats.model.Statistics;
import com.excuseme.rocketleaguelivestats.model.Tier;
import com.excuseme.rocketleaguelivestats.repository.StatisticsRepository;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
Expand All @@ -12,6 +15,7 @@
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import javax.ws.rs.WebApplicationException;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
Expand All @@ -25,26 +29,37 @@ public class APIStatisticsRepository implements StatisticsRepository {
@Override
public Statistics find(String playerId, GamingSystem gamingSystem) {
if(!GamingSystem.BOT.equals(gamingSystem)) {
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
Client client = Client.create(clientConfig);
WebResource webResource = client.resource(URL);
Payload payLoad = webResource.queryParam("platform",gamingSystem.getApiId().toString())
.queryParam("name", playerId)
.header("X-API-KEY", API_KEY)
.accept("application/json")
.get(Payload.class);
if(payLoad != null) {
Statistics statistics = new Statistics();
Stat stat = findStat(payLoad.stats, "Ranked Duel 1v1");
statistics.setOneVsOne(createRank(stat));
stat = findStat(payLoad.stats, "Ranked Doubles 2v2");
statistics.setTwoVsTwo(createRank(stat));
stat = findStat(payLoad.stats, "Ranked Solo Standard 3v3");
statistics.setThreeVSThreeSolo(createRank(stat));
stat = findStat(payLoad.stats, "Ranked Standard 3v3");
statistics.setThreeVsThree(createRank(stat));
return statistics;
try {
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
Client client = Client.create(clientConfig);
WebResource webResource = client.resource(URL);
ClientResponse response = webResource.queryParam("platform", gamingSystem.getApiId().toString())
.queryParam("name", playerId)
.header("X-API-KEY", API_KEY)
.accept("application/json")
.get(ClientResponse.class);

if (response.getStatus() != 200) {
throw new WebApplicationException();
}
Payload payLoad = response.getEntity(Payload.class);

if (payLoad != null) {
Statistics statistics = new Statistics();
Stat stat = findStat(payLoad.stats, "Ranked Duel 1v1");
statistics.setOneVsOne(createRank(stat));
stat = findStat(payLoad.stats, "Ranked Doubles 2v2");
statistics.setTwoVsTwo(createRank(stat));
stat = findStat(payLoad.stats, "Ranked Solo Standard 3v3");
statistics.setThreeVSThreeSolo(createRank(stat));
stat = findStat(payLoad.stats, "Ranked Standard 3v3");
statistics.setThreeVsThree(createRank(stat));
return statistics;
}

} catch (Exception e) {
e.printStackTrace();
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.excuseme.rocketleaguelivestats.repository.GameMapper;
import com.excuseme.rocketleaguelivestats.scanner.TailingFileScanner;
import com.excuseme.rocketleaguelivestats.scanner.model.GameData;
import com.excuseme.rocketleaguelivestats.scanner.model.SessionData;
import com.excuseme.rocketleaguelivestats.view.model.GameViewModel;
import com.excuseme.rocketleaguelivestats.view.model.PlayerViewModel;
import com.excuseme.rocketleaguelivestats.view.model.mapper.PlayerViewModelMapper;
Expand All @@ -32,23 +31,20 @@
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.apache.log4j.Logger;

import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class MainTableView extends Application implements GameDataListener {
private static final String FOLDER = FileSystemView.getFileSystemView().getDefaultDirectory().getPath() + File.separator + "my games" + File.separator + "Rocket League" + File.separator + "TAGame" + File.separator + "Logs" + File.separator;
private static final String LAUNCH = "Launch.log";

private static final Logger LOG = Logger.getLogger(MainTableView.class);
public static final String ROW_TABLE_CSS = "row-table.css";

private final GameViewModel gameViewModel;
Expand Down Expand Up @@ -126,10 +122,8 @@ public void handle(KeyEvent ke) {
}

private void reloadData(Game game) {
LOG.info("Reloading data....");
if (game != null) {
if (!gameViewModel.isSameGame(game)) {
LOG.info("Something changed, updating");
gameViewModel.updateGame(game);
gameUpdated();
playerViewModels.clear();
Expand All @@ -140,7 +134,6 @@ private void reloadData(Game game) {
addNewPlayers(game);
updateItems();
} else {
LOG.info("Same game, won't update");
}
}
}
Expand Down
17 changes: 0 additions & 17 deletions src/main/resources/log4j.properties

This file was deleted.

0 comments on commit b547255

Please sign in to comment.