this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Compatibility rebalance + show compat matches

uwx 758e2970 117313bb

+22 -11
+22 -11
public/main.tsx
··· 826 826 type KinksArray = { section: string, name: string, participant: string, choice: Choice }[]; 827 827 828 828 const compatibilityScoreThresholds = { 829 - Super: 250, 830 - Good: 100, 831 - Decent: 50, 832 - Bad: 25, 829 + Super: 1000, 830 + Good: 500, 831 + Decent: 250, 832 + Bad: 50, 833 833 Poor: 0 834 834 }; 835 835 ··· 934 934 } 935 935 936 936 let score = 0; 937 + let totalMatches = 0; 938 + let possibleMatches = 0; 937 939 for (const [key, myChoice] of myKinks) { 938 940 const otherChoice = otherKinks.get(key); 939 941 if (otherChoice === undefined) continue; 940 942 941 943 score += (similarChoiceWeight[myChoice][otherChoice] ?? 0) * choiceScoreWeight[myChoice]; 944 + 945 + if (myChoice !== 'not-entered' && otherChoice !== 'not-entered') { 946 + if (myChoice === otherChoice) totalMatches++; 947 + possibleMatches++; 948 + } 942 949 } 943 950 944 - return score; 951 + return { score, totalMatches, possibleMatches }; 945 952 } 946 953 947 954 function UserCard({ did, handle, displayName, avatar, myKinks, kinks }: { did: Did, handle?: string, displayName?: string, avatar?: string, myKinks: KinksArray, kinks: KinksArray }) { 948 955 const compatibilityScore = useMemo(() => { 949 - if (!myKinks || !kinks) return 0; 956 + if (!myKinks || !kinks) return { score: 0, totalMatches: 0, possibleMatches: 0 }; 950 957 return getCompatibilityScore(myKinks, kinks); 951 958 }, [myKinks, kinks]); 952 959 960 + const [compatRating, compatEmoji] = useMemo(() => { 961 + if (compatibilityScore.score >= compatibilityScoreThresholds.Super) return ['Super', '๐Ÿฅต']; 962 + if (compatibilityScore.score >= compatibilityScoreThresholds.Good) return ['Good', '๐Ÿ”ฅ']; 963 + if (compatibilityScore.score >= compatibilityScoreThresholds.Decent) return ['Decent', '๐Ÿ™‚']; 964 + if (compatibilityScore.score >= compatibilityScoreThresholds.Bad) return ['Bad', '๐Ÿ˜']; 965 + return ['Poor', '๐Ÿ˜ข']; 966 + }, [compatibilityScore.score]); 967 + 953 968 console.log('Compatibility score for', handle, 'is', compatibilityScore); 954 969 955 970 return ( ··· 971 986 </div> 972 987 973 988 <div class="content"> 974 - {compatibilityScore >= compatibilityScoreThresholds.Super ? <p><strong>Compatibility: Super</strong> ๐Ÿฅต</p> 975 - : compatibilityScore >= compatibilityScoreThresholds.Good ? <p><strong>Compatibility: Good</strong> ๐Ÿ”ฅ</p> 976 - : compatibilityScore >= compatibilityScoreThresholds.Decent ? <p><strong>Compatibility: Decent</strong> ๐Ÿ™‚</p> 977 - : compatibilityScore >= compatibilityScoreThresholds.Bad ? <p><strong>Compatibility: Bad</strong> ๐Ÿ˜</p> 978 - : <p><strong>Compatibility: Zero!</strong> ๐Ÿ˜ข</p>} 989 + <p>Compatibility: <strong>{compatRating}</strong> {compatEmoji} ({compatibilityScore.totalMatches}/{compatibilityScore.possibleMatches})</p> 979 990 </div> 980 991 </div> 981 992 </div>