Skip to content

Username page shows far fewer packages than npm #1888

@maxchang3

Description

@maxchang3

Describe the bug

The package count on the username page is far lower than on npmjs.com.

Example :

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 npm triggers 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>/package returns 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backServer, DatafrontFrontend, Designp2Priority 2 bug (medium)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions