@@ -103,7 +103,7 @@ export async function calculatePartnerRanking({
103103 status === "discover"
104104 ? starred === true
105105 ? Prisma . sql `dp.starredAt ASC`
106- : Prisma . sql `finalScore DESC, ${ hasProfileCheck } DESC, p.id ASC`
106+ : Prisma . sql `finalScore DESC, p.id ASC`
107107 : status === "invited"
108108 ? Prisma . sql `dp.invitedAt ASC`
109109 : Prisma . sql `enrolled.createdAt DESC, p.id ASC` ;
@@ -232,10 +232,16 @@ export async function calculatePartnerRanking({
232232 CASE WHEN enrolled.status = 'approved' THEN enrolled.createdAt ELSE NULL END as recruitedAt,
233233 preferredEarningStructuresData.preferredEarningStructures as preferredEarningStructures,
234234 salesChannelsData.salesChannels as salesChannels,
235+
236+ -- Pre-compute hasProfileCheck for faster sorting
237+ ${ hasProfileCheck } as hasProfile,
235238
236- -- FINAL SCORE (0-265 + points): Similarity-based ranking for discovery
239+ -- FINAL SCORE (0-765 + points): Similarity-based ranking for discovery
237240 -- Trusted partners (trustedAt IS NOT NULL) get 200 bonus points to rank at the top
241+ -- Partners with profiles get 500 bonus points to ensure they rank above those without profiles
238242 (
243+ -- Profile bonus: 500 points for partners with online presence (ensures they rank above those without)
244+ CASE WHEN ${ hasProfileCheck } THEN 500 ELSE 0 END +
239245 -- Trusted partner bonus: 200 points for partners with trustedAt set
240246 CASE WHEN p.trustedAt IS NOT NULL THEN 200 ELSE 0 END +
241247 COALESCE(similarProgramMetrics.similarityScore, 0) +
0 commit comments