Skip to content

Commit

Permalink
feat(heroes-radar): remove equal total equal rank logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorsAngerVaNeT committed Aug 27, 2023
1 parent fc2e220 commit df728dd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nestjs/src/gratitudes/dto/heroes-radar.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ interface HeroesRadar {
}

const calculateRank = ({ heroes, meta }: HeroesRadar): HeroRadar[] => {
const sortedHeroes = [...heroes].sort((a, b) => b.total - a.total);
const rankedHeroes = heroes.map(hero => {
const rank = sortedHeroes.findIndex(h => h.total === hero.total) + 1 + meta.pageSize * (meta.current - 1);
const rankedHeroes = heroes.map((hero, index) => {
const rank = index + 1 + meta.pageSize * (meta.current - 1);
return { ...hero, rank };
});
return rankedHeroes;
Expand Down

0 comments on commit df728dd

Please sign in to comment.