Skip to content

Commit

Permalink
Merge pull request #787 from bounswe/be/fix_rank_bug
Browse files Browse the repository at this point in the history
be/fix ranking bug
  • Loading branch information
Alputer authored Dec 25, 2023
2 parents 22313fa + 99fdcd2 commit 5864523
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/backend/src/ranking/ranking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ export class RankingService {
return response;
}

async findAllMyRankings(userID:string) {
async findAllMyRankings(userId:string) {
const myRankings = await this.rankingRepository
.createQueryBuilder('ranking')
.select(['user.id', 'user.username', 'tag.id', 'tag.name', 'ranking.score'])
.addSelect('RANK() OVER (PARTITION BY tag.id ORDER BY ranking.score DESC) AS rank')
.innerJoin('ranking.user', 'user')
.innerJoin('ranking.tag', 'tag')
.where('user.id = :userID', { userID })
.createQueryBuilder('rankings')
.select(['tags.id tag_id', 'tags.name tag_name','users.id user_id','users.username user_username', 'rankings.score ranking_score'])
.addSelect('(RANK() OVER (PARTITION BY tags.id ORDER BY rankings.score DESC)) AS "rank"')
.innerJoin('rankings.user', 'users')
.innerJoin('rankings.tag', 'tags')
.orderBy('tags.id, "rank"')
.getRawMany();

return myRankings;
const filteredResults = myRankings.filter(result => result.user_id === userId);
return filteredResults;
}


async settlePoints(poll: Poll,option: Option){
const votes : Vote[] = await this.voteRepository.find({
Expand Down

0 comments on commit 5864523

Please sign in to comment.