Search in sources :

Example 1 with SzRecord

use of com.faendir.zachtronics.bot.sz.model.SzRecord in project zachtronics-leaderboard-bot by F43nd1r.

the class SzController method getRecord.

@Override
public SzRecordDTO getRecord(@NotNull String puzzleId, @NotNull String categoryId) {
    SzPuzzle puzzle = findPuzzle(puzzleId);
    SzCategory category = findCategory(categoryId);
    SzRecord record = repository.find(puzzle, category);
    if (record != null)
        return SzRecordDTO.fromCategoryRecord(new CategoryRecord<>(record, EnumSet.of(category)));
    else
        return null;
}
Also used : SzPuzzle(com.faendir.zachtronics.bot.sz.model.SzPuzzle) CategoryRecord(com.faendir.zachtronics.bot.repository.CategoryRecord) SzCategory(com.faendir.zachtronics.bot.sz.model.SzCategory) SzRecord(com.faendir.zachtronics.bot.sz.model.SzRecord)

Example 2 with SzRecord

use of com.faendir.zachtronics.bot.sz.model.SzRecord in project zachtronics-leaderboard-bot by F43nd1r.

the class SzRecordDTO method fromCategoryRecord.

@NotNull
public static SzRecordDTO fromCategoryRecord(@NotNull CategoryRecord<SzRecord, SzCategory> categoryRecord) {
    SzRecord record = categoryRecord.getRecord();
    Set<SzCategory> categories = categoryRecord.getCategories();
    return new SzRecordDTO(SzScoreDTO.fromScore(record.getScore()), record.getScore().toDisplayString(DisplayContext.plainText()), record.getAuthor(), record.getDataLink(), UtilsKt.smartFormat(categories, UtilsKt.toMetricsTree(record.getPuzzle().getSupportedCategories())));
}
Also used : SzCategory(com.faendir.zachtronics.bot.sz.model.SzCategory) SzRecord(com.faendir.zachtronics.bot.sz.model.SzRecord) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SzCategory (com.faendir.zachtronics.bot.sz.model.SzCategory)2 SzRecord (com.faendir.zachtronics.bot.sz.model.SzRecord)2 CategoryRecord (com.faendir.zachtronics.bot.repository.CategoryRecord)1 SzPuzzle (com.faendir.zachtronics.bot.sz.model.SzPuzzle)1 NotNull (org.jetbrains.annotations.NotNull)1