Skip to content

Commit c6ed0f4

Browse files
authored
Merge pull request #297 from nursoltan-s/poc-recommender-nursoltan-s-1
fix sort by descending best score
2 parents fe7ea5a + 7b24787 commit c6ed0f4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/services/challenges.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,12 @@ class ChallengesService {
558558
if (filter.tracks.Des) tracks.push('Design');
559559
if (filter.tracks.Dev) tracks.push('Development');
560560
if (filter.tracks.QA) tracks.push('Quality Assurance');
561-
if (filter.openForRegistration === 'best-match' || sort.openForRegistration === {}) {
562-
sortedChallenges = _.sortBy(mockRecommendedChallenges, ['matchScore']);
561+
if (sort.openForRegistration === 'bestMatch' || sort.openForRegistration === {}) {
562+
const ascArray = _.sortBy(mockRecommendedChallenges, [
563+
item => Math.trunc((parseFloat(item.matchScore) + 1.0) / 2.0 * 100.0)]);
564+
sortedChallenges = _.reverse(ascArray);
565+
} else if (sort.openForRegistration === 'name') {
566+
sortedChallenges = _.sortBy(mockRecommendedChallenges, ['name']);
563567
} else {
564568
sortedChallenges = _.sortBy(mockRecommendedChallenges, [sort.openForRegistration]);
565569
}

0 commit comments

Comments
 (0)