use of com.skelril.skree.db.schema.tables.HighScores.HIGH_SCORES in project Skree by Skelril.
the class HighScoreDatabaseUtil method getTop.
public static List<Clause<Optional<GameProfile>, Integer>> getTop(ScoreType scoreType, int count) {
try (Connection con = SQLHandle.getConnection()) {
DSLContext create = DSL.using(con);
Result<Record2<String, Integer>> results = create.select(PLAYERS.UUID, HIGH_SCORES.VALUE).from(HIGH_SCORES).join(PLAYERS).on(PLAYERS.ID.equal(HIGH_SCORES.PLAYER_ID)).where(HIGH_SCORES.SCORE_TYPE_ID.equal(scoreType.getId())).orderBy(scoreType.getOrder() == ScoreType.Order.ASC ? HIGH_SCORES.VALUE.asc() : HIGH_SCORES.VALUE.desc()).limit(count).fetch();
return results.stream().map(record -> new Clause<>(getProfile(record.getValue(PLAYERS.UUID)), record.getValue(HIGH_SCORES.VALUE))).collect(Collectors.toList());
} catch (SQLException e) {
e.printStackTrace();
}
return Lists.newArrayList();
}
Aggregations