Created
June 21, 2019 21:57
-
-
Save amupoti/633cba8fdb76409f2119da5ec7f58a7d to your computer and use it in GitHub Desktop.
Export boardgamestats player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void extractPlayers() { | |
ObjectMapper objectMapper = new ObjectMapper(); | |
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |
try { | |
BoardGameStats bgs = objectMapper.readValue(new File("target/bg.json"), BoardGameStats.class); | |
List<Play> collect = bgs.getPlays().stream().filter(p -> p.playerScores.stream().anyMatch(ps -> ps.playerRefId == 33)).collect(Collectors.toList()); | |
log.info("there are {} plays for player 33", collect.size()); | |
objectMapper.writeValue(new File("target/output.json"), collect); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
@Data | |
static class BoardGameStats { | |
private List<Play> plays; | |
} | |
@Data | |
static class Play { | |
private String uuid; | |
private String modificationDate; | |
private String entryDate; | |
private String playDate; | |
private Boolean usesTeams; | |
private int durationMin; | |
private Boolean ignored; | |
private Boolean manualWinner; | |
private int rounds; | |
private int bggId; | |
private int locationRefId; | |
private int gameRefId; | |
private int rating; | |
private int nemestatsId; | |
private int scoringSetting; | |
private List<PlayerScore> playerScores; | |
} | |
@Data | |
static class PlayerScore { | |
private String score; | |
private Boolean winner; | |
private Boolean newPlayer; | |
private Boolean startPlayer; | |
private int playerRefId; | |
private int rank; | |
private int seatOrder; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment