Skip to content

Commit 510dc34

Browse files
committed
fix: update sort results
1 parent 01fd072 commit 510dc34

File tree

2 files changed

+18
-30
lines changed

2 files changed

+18
-30
lines changed

app/pages/search.vue

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,6 @@ const displayResults = computed(() => {
223223
case 'name':
224224
diff = a.package.name.localeCompare(b.package.name)
225225
break
226-
case 'quality':
227-
diff = (a.score?.detail?.quality ?? 0) - (b.score?.detail?.quality ?? 0)
228-
break
229-
case 'popularity':
230-
diff = (a.score?.detail?.popularity ?? 0) - (b.score?.detail?.popularity ?? 0)
231-
break
232-
case 'maintenance':
233-
diff = (a.score?.detail?.maintenance ?? 0) - (b.score?.detail?.maintenance ?? 0)
234-
break
235-
case 'score':
236-
diff = (a.score?.final ?? 0) - (b.score?.final ?? 0)
237-
break
238226
default:
239227
diff = 0
240228
}

shared/types/preferences.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,32 +140,32 @@ export const SORT_KEYS: SortKeyConfig[] = [
140140
{ key: 'downloads-year', defaultDirection: 'desc', disabled: true },
141141
{ key: 'updated', defaultDirection: 'desc' },
142142
{ key: 'name', defaultDirection: 'asc' },
143-
{ key: 'quality', defaultDirection: 'desc' },
144-
{ key: 'popularity', defaultDirection: 'desc' },
145-
{ key: 'maintenance', defaultDirection: 'desc' },
146-
{ key: 'score', defaultDirection: 'desc' },
143+
// quality/popularity/maintenance: npm returns 1 for all, Algolia returns synthetic values.
144+
// Neither provider produces meaningful values for these.
145+
{ key: 'quality', defaultDirection: 'desc', disabled: true },
146+
{ key: 'popularity', defaultDirection: 'desc', disabled: true },
147+
{ key: 'maintenance', defaultDirection: 'desc', disabled: true },
148+
// score.final === searchScore (identical to relevance), redundant sort key
149+
{ key: 'score', defaultDirection: 'desc', disabled: true },
147150
]
148151

149152
/**
150153
* Sort keys each search provider can meaningfully sort by.
151154
*
152-
* Algolia: has download counts and dates but synthetic/zeroed score values
153-
* - quality is 0 or 1 (boolean `popular` flag), maintenance is always 0, score is always 0
154-
* - popularity is `downloadsRatio` (a meaningful float)
155+
* Both providers support: relevance (server-side order), updated, name.
155156
*
156-
* npm: has real score values and dates but no download counts in search results
157+
* Algolia: has `downloadsLast30Days` for download sorting.
158+
*
159+
* npm: the search API now includes `downloads.weekly` and `downloads.monthly`
160+
* directly in results, so download sorting works here too.
161+
*
162+
* Neither provider returns useful quality/popularity/maintenance/score values:
163+
* - npm returns 1 for all detail scores, and score.final === searchScore (= relevance)
164+
* - Algolia returns synthetic values (quality: 0|1, maintenance: 0, score: 0)
157165
*/
158166
export const PROVIDER_SORT_KEYS: Record<'algolia' | 'npm', Set<SortKey>> = {
159-
algolia: new Set<SortKey>(['relevance', 'downloads-week', 'updated', 'name', 'popularity']),
160-
npm: new Set<SortKey>([
161-
'relevance',
162-
'updated',
163-
'name',
164-
'quality',
165-
'popularity',
166-
'maintenance',
167-
'score',
168-
]),
167+
algolia: new Set<SortKey>(['relevance', 'downloads-week', 'updated', 'name']),
168+
npm: new Set<SortKey>(['relevance', 'downloads-week', 'updated', 'name']),
169169
}
170170

171171
/** All valid sort keys for validation */

0 commit comments

Comments
 (0)