use of com.faendir.zachtronics.bot.inf.model.IfRecord in project zachtronics-leaderboard-bot by F43nd1r.
the class IfController method getRecord.
@GetMapping(path = "/puzzle/{puzzleId}/category/{categoryId}/record", produces = MediaType.APPLICATION_JSON_VALUE)
public IfRecordDTO getRecord(@PathVariable String puzzleId, @PathVariable String categoryId) {
IfPuzzle puzzle = findPuzzle(puzzleId);
IfCategory category = findCategory(categoryId);
IfRecord record = repository.find(puzzle, category);
if (record != null)
return IfRecordDTO.fromCategoryRecord(new CategoryRecord<>(record, EnumSet.of(category)));
else
return null;
}
use of com.faendir.zachtronics.bot.inf.model.IfRecord in project zachtronics-leaderboard-bot by F43nd1r.
the class IfRecordDTO method fromCategoryRecord.
@NotNull
public static IfRecordDTO fromCategoryRecord(@NotNull CategoryRecord<IfRecord, IfCategory> categoryRecord) {
IfRecord record = categoryRecord.getRecord();
Set<IfCategory> categories = categoryRecord.getCategories();
return new IfRecordDTO(IfScoreDTO.fromScore(record.getScore()), record.getScore().toDisplayString(DisplayContext.plainText()), record.getAuthor(), record.getDataLink(), UtilsKt.smartFormat(categories, UtilsKt.toMetricsTree(record.getPuzzle().getSupportedCategories())));
}
Aggregations