don't use the score DTO
This commit is contained in:
parent
5cd026c025
commit
b479304d8a
@ -1,7 +1,7 @@
|
||||
package cc.fascinated.controller;
|
||||
|
||||
import cc.fascinated.exception.impl.BadRequestException;
|
||||
import cc.fascinated.model.score.TrackedScoreDTO;
|
||||
import cc.fascinated.model.score.TrackedScore;
|
||||
import cc.fascinated.platform.Platform;
|
||||
import cc.fascinated.services.TrackedScoreService;
|
||||
import lombok.NonNull;
|
||||
@ -38,7 +38,7 @@ public class ScoresController {
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping(value = "/top/{platform}")
|
||||
public ResponseEntity<List<TrackedScoreDTO>> getTopScores(@PathVariable String platform) {
|
||||
public ResponseEntity<List<?>> getTopScores(@PathVariable String platform) {
|
||||
return ResponseEntity.ok(trackedScoreService.getTopScores(Platform.Platforms.getPlatform(platform), 100));
|
||||
}
|
||||
|
||||
|
@ -96,11 +96,4 @@ public class TrackedScore {
|
||||
* The timestamp of the score.
|
||||
*/
|
||||
private Date timestamp;
|
||||
|
||||
/**
|
||||
* Gets the Tracked Score as a DTO
|
||||
*/
|
||||
public TrackedScoreDTO getAsDTO() {
|
||||
return new TrackedScoreDTO(scoreId, playerId, leaderboardId, pp, rank, score, missedNotes, accuracy, timestamp);
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
package cc.fascinated.model.score;
|
||||
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class TrackedScoreDTO {
|
||||
/**
|
||||
* The ID of the score.
|
||||
*/
|
||||
@Id
|
||||
private String scoreId;
|
||||
|
||||
/**
|
||||
* The ID of the player who set the score.
|
||||
*/
|
||||
private String playerId;
|
||||
|
||||
/**
|
||||
* The ID of the leaderboard.
|
||||
*/
|
||||
private String leaderboardId;
|
||||
|
||||
/**
|
||||
* The PP of the score.
|
||||
*/
|
||||
private Double pp;
|
||||
|
||||
/**
|
||||
* The rank of the score.
|
||||
*/
|
||||
private Long rank;
|
||||
|
||||
/**
|
||||
* The base score of the score.
|
||||
*/
|
||||
private Long score;
|
||||
|
||||
/**
|
||||
* The number of misses in the score.
|
||||
*/
|
||||
private Long missedNotes;
|
||||
|
||||
/**
|
||||
* The accuracy of the score.
|
||||
*/
|
||||
private Double accuracy;
|
||||
|
||||
/**
|
||||
* The timestamp of the score.
|
||||
*/
|
||||
private Date timestamp;
|
||||
}
|
@ -4,7 +4,6 @@ import cc.fascinated.exception.impl.BadRequestException;
|
||||
import cc.fascinated.model.score.ScoresOverResponse;
|
||||
import cc.fascinated.model.score.TotalScoresResponse;
|
||||
import cc.fascinated.model.score.TrackedScore;
|
||||
import cc.fascinated.model.score.TrackedScoreDTO;
|
||||
import cc.fascinated.platform.Platform;
|
||||
import cc.fascinated.repository.couchdb.TrackedScoreRepository;
|
||||
import lombok.NonNull;
|
||||
@ -42,12 +41,12 @@ public class TrackedScoreService {
|
||||
* @param amount the amount of scores to get
|
||||
* @return the scores
|
||||
*/
|
||||
public List<TrackedScoreDTO> getTopScores(Platform.Platforms platform, int amount) {
|
||||
public List<TrackedScore> getTopScores(Platform.Platforms platform, int amount) {
|
||||
List<TrackedScore> scores = trackedScoreRepository.findTopRankedScores(platform.getPlatformName(), amount);
|
||||
if (scores.isEmpty()) {
|
||||
throw new BadRequestException("No scores found for platform " + platform.getPlatformName());
|
||||
}
|
||||
return scores.stream().map(TrackedScore::getAsDTO).toList();
|
||||
return scores;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user