Skip to content

Commit f9e8d12

Browse files
authored
Merge pull request #5330 from nursoltan-s/poc-recommender-nursoltan-s
fix sort by descending best score
2 parents c332731 + 2e1ebbf commit f9e8d12

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export default function FiltersPanel({
267267
setRecommendedToggle(on);
268268

269269
if (on) {
270-
setSort('openForRegistration', 'updatedBy');
270+
setSort('openForRegistration', 'bestMatch');
271271
setFilterState({ ..._.clone(filterState), types });
272272
} else {
273273
setFilterState({ ..._.clone(filterState), types: ['TSK', 'CH', 'F2F'] });

src/shared/components/challenge-listing/Listing/Bucket/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default function Bucket({
5454
setSearchText,
5555
}) {
5656
const activeBucketData = isRecommendedChallengeType(bucket, filterState)
57-
? BUCKET_DATA[bucket].sorts : BUCKET_DATA[bucket].sorts.filter(item => item !== 'updatedBy');
57+
? BUCKET_DATA[bucket].sorts : BUCKET_DATA[bucket].sorts.filter(item => item !== 'bestMatch');
5858

5959
let noLiveBucket = activeBucket;
6060
if (isRecommendedChallengeType(bucket, filterState)) {

src/shared/utils/challenge-listing/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ export function phaseStartDate(phase) {
3939
* @param {Float} score
4040
*/
4141
export function calculateScore(score) {
42-
return Math.trunc(Math.abs(score + 1.0) * 100.0 / 2.0);
42+
return Math.trunc((parseFloat(score) + 1.0) / 2.0 * 100.0);
4343
}

src/shared/utils/challenge-listing/sort.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import moment from 'moment';
66
import { sumBy } from 'lodash';
7+
import { calculateScore } from './helper';
78
// import { phaseStartDate, phaseEndDate } from './helper';
89

910
export const SORTS = {
@@ -19,7 +20,7 @@ export const SORTS = {
1920
REVIEW_OPPORTUNITIES_TITLE_A_TO_Z: 'review-opportunities-title-a-to-z',
2021
REVIEW_OPPORTUNITIES_PAYMENT: 'review-opportunities-payment',
2122
REVIEW_OPPORTUNITIES_START_DATE: 'review-opportunities-start-date',
22-
BEST_MATCH: 'updatedBy',
23+
BEST_MATCH: 'bestMatch',
2324
};
2425

2526
export default {
@@ -100,8 +101,7 @@ export default {
100101
name: 'Review start date',
101102
},
102103
[SORTS.BEST_MATCH]: {
103-
func: (a, b) => parseFloat(a.matchScore) - parseFloat(b.matchScore),
104+
func: (a, b) => calculateScore(b.matchScore) - calculateScore(a.matchScore),
104105
name: 'Best Match',
105-
order: 'asc',
106106
},
107107
};

0 commit comments

Comments
 (0)