Skip to content

Change package title could affect the version ordering in search requests #1601

@mrodm

Description

@mrodm

As mentioned in #1585 , changing the title of a package in a given version could affect the ordering of packages shown in the search requests (setting the all=true query parameter).

For instance, 1password package change its title in 1.4.0 and this could affect how packages are sorted:

$ curl -s "https://epr.elastic.co/search?package=1password&all=true" | jq -r '.[] | {name, title, version}'
{
  "name": "1password",
  "title": "1Password",
  "version": "1.10.0"
}
{
  "name": "1password",
  "title": "1Password",
  "version": "1.11.0"
}
{
  "name": "1password",
  "title": "1Password",
  "version": "1.12.0"
}
...
{
  "name": "1password",
  "title": "1Password",
  "version": "1.33.0"
}
{
  "name": "1password",
  "title": "1Password",
  "version": "1.34.0"
}
{
  "name": "1password",
  "title": "1Password",
  "version": "1.4.0"
}
...
{
  "name": "1password",
  "title": "1Password",
  "version": "1.9.0"
}
{
  "name": "1password",
  "title": "1Password Events Reporting",
  "version": "0.1.1"
}
{
  "name": "1password",
  "title": "1Password Events Reporting",
  "version": "0.2.0"
}
...
{
  "name": "1password",
  "title": "1Password Events Reporting",
  "version": "1.3.0"
}

Related code where packages are sorted first by title and then by version:

func (p Packages) Less(i, j int) bool {
if p[i].Title != nil && p[j].Title != nil && *p[i].Title != *p[j].Title {
return *p[i].Title < *p[j].Title
}
return p[i].Version < p[j].Version
}

Relates:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Team:EcosystemLabel for the Packages Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions