diff --git a/src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx b/src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx index 2b097830b7..68c534e371 100644 --- a/src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx +++ b/src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx @@ -267,7 +267,7 @@ export default function FiltersPanel({ setRecommendedToggle(on); if (on) { - setSort('openForRegistration', 'updatedBy'); + setSort('openForRegistration', 'bestMatch'); setFilterState({ ..._.clone(filterState), types }); } else { setFilterState({ ..._.clone(filterState), types: ['TSK', 'CH', 'F2F'] }); diff --git a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx index 86fa8dcb1b..a13e429c29 100644 --- a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx +++ b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx @@ -54,7 +54,7 @@ export default function Bucket({ setSearchText, }) { const activeBucketData = isRecommendedChallengeType(bucket, filterState) - ? BUCKET_DATA[bucket].sorts : BUCKET_DATA[bucket].sorts.filter(item => item !== 'updatedBy'); + ? BUCKET_DATA[bucket].sorts : BUCKET_DATA[bucket].sorts.filter(item => item !== 'bestMatch'); let noLiveBucket = activeBucket; if (isRecommendedChallengeType(bucket, filterState)) { diff --git a/src/shared/utils/challenge-listing/helper.js b/src/shared/utils/challenge-listing/helper.js index acdfd03ba1..f88506e2ae 100644 --- a/src/shared/utils/challenge-listing/helper.js +++ b/src/shared/utils/challenge-listing/helper.js @@ -39,5 +39,5 @@ export function phaseStartDate(phase) { * @param {Float} score */ export function calculateScore(score) { - return Math.trunc(Math.abs(score + 1.0) * 100.0 / 2.0); + return Math.trunc((parseFloat(score) + 1.0) / 2.0 * 100.0); } diff --git a/src/shared/utils/challenge-listing/sort.js b/src/shared/utils/challenge-listing/sort.js index 3ac75f6cfa..fbce202b88 100644 --- a/src/shared/utils/challenge-listing/sort.js +++ b/src/shared/utils/challenge-listing/sort.js @@ -4,6 +4,7 @@ import moment from 'moment'; import { sumBy } from 'lodash'; +import { calculateScore } from './helper'; // import { phaseStartDate, phaseEndDate } from './helper'; export const SORTS = { @@ -19,7 +20,7 @@ export const SORTS = { REVIEW_OPPORTUNITIES_TITLE_A_TO_Z: 'review-opportunities-title-a-to-z', REVIEW_OPPORTUNITIES_PAYMENT: 'review-opportunities-payment', REVIEW_OPPORTUNITIES_START_DATE: 'review-opportunities-start-date', - BEST_MATCH: 'updatedBy', + BEST_MATCH: 'bestMatch', }; export default { @@ -100,8 +101,7 @@ export default { name: 'Review start date', }, [SORTS.BEST_MATCH]: { - func: (a, b) => parseFloat(a.matchScore) - parseFloat(b.matchScore), + func: (a, b) => calculateScore(b.matchScore) - calculateScore(a.matchScore), name: 'Best Match', - order: 'asc', }, };