-
-
Notifications
You must be signed in to change notification settings - Fork 379
Description
Describe the bug
The package count on the username page is far lower than on npmjs.com.
Example :
- npmx: https://npmx.dev/~yyx990803
- 61 public packages (data source: Algolia)
- 318 public packages (data source: npm registry)
- npm: https://www.npmjs.com/~yyx990803
- 328 packages
Additional context
For Algolia
I suspect the issue is that the code currently filters only by owner.name and should either include both owner.name and owners.name, or filter by owners.name alone.
| filters: `owner.name:${ownerName}`, |
I tried changing it to owners locally, got 0 results, and had to fall back to npm. It seems that owners should be included in attributesForFaceting in npm-search to make this work.
For testing purposes, the following query can approximate a full package list:
const { results } = await client.search({
requests: [
{
indexName,
query: ownerName,
offset,
length,
restrictSearchableAttributes: ['owners.name'],
typoTolerance: false,
removeWordsIfNoResults: 'none',
analyticsTags: ['npmx.dev'],
attributesToRetrieve: ATTRIBUTES_TO_RETRIEVE,
attributesToHighlight: [],
} satisfies SearchQuery,
],
})For npm registry
Note: Currently, setting the data source to
npmtriggers an error: "This user may not exist or has no public packages." This is related to issue #1948.
From #2057, it seems that
https://registry.npmjs.org/-/org/<org_name>/package (https://npmx.dev/api/registry/org/<org_name>/packages)
also accepts a username and returns a result that is identical to what npmjs.com shows, including deprecated packages.
Edit:
https://registry.npmjs.org/-/user/<username>/packagereturns the same data as well.
This might be useful for improving how the user page retrieves packages. For the npm data source, we could fetch a list of all packages via this API, then retrieve metadata separately.
However, it might also cause the same issue as #208.
Referring to #1978, I compared the examples listed there.
| # | Username | Algolia (npmx.dev) | npmjs.com | org/<username>/packages |
|---|---|---|---|---|
| 1 | ~dbushell | 19 | 15 | 15 |
| 2 | ~fb | 434 | 465 | 465 |
| 3 | ~pi0 | 438 | 658 | 658 |
| 4 | ~danielroe | 106 | 649 | 649 |
| 5 | ~posva | 118 | 119 | 119 |
| 6 | ~rich_harris | 39 | 510 | 510 |
| 7 | ~yyx990803 | 61 | 329 | 329 |