diff --git a/web/src/utils/userLevelCalculation.ts b/web/src/utils/userLevelCalculation.ts index fdb7218ac..d31fc348c 100644 --- a/web/src/utils/userLevelCalculation.ts +++ b/web/src/utils/userLevelCalculation.ts @@ -15,9 +15,8 @@ const levelCriteria: ILevelCriteria[] = [ ]; export const getUserLevelData = (coherenceScore: number, totalResolvedDisputes: number) => { - for (const criteria of levelCriteria) { + for (const criteria of [...levelCriteria].sort((a, b) => b.level - a.level)) { if ( - criteria.level > 0 && totalResolvedDisputes >= criteria.minDisputes && coherenceScore >= criteria.minScore && coherenceScore <= criteria.maxScore @@ -26,13 +25,5 @@ export const getUserLevelData = (coherenceScore: number, totalResolvedDisputes: } } - if ( - totalResolvedDisputes >= levelCriteria[0].minDisputes && - coherenceScore >= levelCriteria[0].minScore && - coherenceScore <= levelCriteria[0].maxScore - ) { - return levelCriteria[0]; - } - return levelCriteria.find(({ level }) => level === 1); };