Skip to content

Conversation

bartvanandel
Copy link
Contributor

@bartvanandel bartvanandel commented Jul 20, 2018

Description Of Changes

This change adds a new command line option "order-by", allowing the user to specify a few sorting strategies. By default the results will be sorted by id.

Motivation and Context

To allow uses to decide how they want the results being sorted when we can.

Testing

These tests assume you only have the Chocolatey Community Repository enabled as a source.

  1. Do a search using choco search chrome --order-by='id'
  2. Verify the resulting set is ordered by the Identifier with the first entry being 1password-chrome
  3. Do the same search using --order-by='title'
  4. Verify the first entry is choco-protocol-support (It is prefixed with (unofficial) in the title, and is expected to be the first result in this case.
  5. Search again using --order-by='popularity'
  6. Verify the package with most downloads is returned first (at this time it is GoogleChrome).
  7. Search again using --order-by='unsorted'
  8. Go to https://community.chocolatey.org/packages` and enter chrome in the search box and hit enter.
  9. Verify the order of the search on Chocolatey Community Repository and the results from Chocolatey CLI is in the same/similar order.
  10. Search again using --order-by='LastPublished'.
  11. Verify a yellow warning is outputted with the text Order By 'LastPublished' has been specified. This order is done on client side and may lead to inconsistently ordered results.
  12. Go to the website search previously made, and change the dropdown for the order to Recent.
  13. Verify the order of packages is similar to the output from the Chocolatey CLI output (they may not be exactly the same due to client sort).
  14. Search again using --order-by='other'.
  15. Verify an error is outputted with the message Error: The order-by clause 'other' is not recognized. Use one of the supported clauses: 'Id', 'LastPublished', 'Popularity', 'Title', 'Unsorted'..

Operating Systems Testing

  • Windows 11

Change Types Made

  • Feature / Enhancement (non-breaking change).

Change Checklist

  • Requires a change to the documentation.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?

Related Issue

Fixes #3709

Additional Information

Note that some results may appear out-of-order, this is caused by the NuGet server returning them in the incorrect order, see chocolatey/NuGet.Server-chocolatey#2

Copy link
Member

@ferventcoder ferventcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bartvanandel, thanks for taking a stab, this is a great start! I left a couple of comments here for you to look at. Apologies on not getting back sooner. We tend to sit the project down for a bit and then pick it up when we get closer to release. If you are unable make the adjustments, we can always take a look at them for you - however they are not as likely to make it into this release. HTH

@ferventcoder
Copy link
Member

Minor nitpick, the git commit body (the message) needs to split at 72/80 characters as well.

@bartvanandel
Copy link
Contributor Author

Minor nitpick, the git commit body (the message) needs to split at 72/80 characters as well.

Do you want 72 or 80?

@ferventcoder
Copy link
Member

72 is what CONTRIBUTING states -
https://github.com/chocolatey/choco/blob/master/CONTRIBUTING.md#prepare-commits

@bartvanandel bartvanandel force-pushed the feat/order-by-parameter branch 2 times, most recently from bd1f31a to 6412eaf Compare January 20, 2019 21:57
@bartvanandel
Copy link
Contributor Author

Wrapped commit body at 72 chars as requested.

@bartvanandel bartvanandel force-pushed the feat/order-by-parameter branch from 6412eaf to 47c339c Compare January 20, 2019 22:37
@bartvanandel
Copy link
Contributor Author

Just pushed a change to satisfy AppVeyor. Unfortunately Travis crashed before compilation even started. Anyway, any other changes you require before you decide to merge this pull request?

@bartvanandel
Copy link
Contributor Author

@ferventcoder I put some effort into this branch 22 to 15 months ago, you requested some changes which I resolved back then, but after that, silence... I can try to rebase this onto current master (or merge master into this branch, which seems reasonable enough to me, you can squash merge anyway), but are you going to try and merge it after I do? The issue is still open so I assume it's still not fixed, but I don't feel like putting effort into this and being neglected again.

@CLAassistant
Copy link

CLAassistant commented Jun 8, 2020

CLA assistant check
All committers have signed the CLA.

@bartvanandel
Copy link
Contributor Author

Weird. Codacy says there are 2 new issues, but when diving into the details by following the links you end up not seeing them in code. Also, Travis fails with an internal error, I don't think I can fix that. @ferventcoder can you see what's going on?

@ferventcoder
Copy link
Member

@bartvanandel Yes, these are good changes. You can rebase or we can manage the rebase for you. I would say ignore Codacy at this point. I think Travis is likely failing here due to the merge conflict as it is trying to build/run it as if it is merged in.

@bartvanandel
Copy link
Contributor Author

Well, happy to contribute! I think it's probably fastest if you do the rebase, as you know better about what has changed than I do (I basically don't have a clue at this point ;-) and you can merge directly when it's done.

@bartvanandel
Copy link
Contributor Author

@ferventcoder any progress on this PR?

@bartvanandel
Copy link
Contributor Author

@ferventcoder hello?

@bartvanandel
Copy link
Contributor Author

@ferventcoder Are you going to resolve the merge conflicts and merge this branch at some point? This PR is over 2 years old and still applies. I put some effort into it, so it would be nice to see the results in a released version of the product at some point...

@bartvanandel
Copy link
Contributor Author

BTW I don't think your earlier reviews apply anymore, those were resolved a year and a half ago, but due to rewritten history (as requested, because of the rebase) the commits that were reviewed cannot be found anymore. Basically the review is currently a dead-end street.

@bartvanandel
Copy link
Contributor Author

bartvanandel commented Mar 25, 2021

@ferventcoder Any chance this PR is ever going to be merged? I just ran choco search screen and I'm still annoyed by the apparent lack of order in the 241 results long output. The PR is now over 2 years old...

BTW I suggest that you take a look at any merge conflicts, I've resolved them in the past but I don't feel like resolving them again only to see the PR still not being merged.

@bartvanandel
Copy link
Contributor Author

@gep13 Are you the new maintainer? Would you be willing to finish up and merge this long-standing pull request?

@bartvanandel
Copy link
Contributor Author

bartvanandel commented Sep 22, 2021

I give up. For more than 3 I've tried to get this PR reviewed and merged, but @ferventcoder doesn't seem interested enough.

@chocolatey chocolatey deleted a comment from bartvanandel Sep 27, 2021
@gep13 gep13 changed the title (GH-256) Add order-by parameter and sort packages by name by default (#256) Add order-by parameter and sort packages by name by default Oct 15, 2021
@gep13
Copy link
Member

gep13 commented May 15, 2025

We will also need to look at deprecating the --order-by-popularity option, as this is essentially duplicated by --order-by="popularity"

@bartvanandel
Copy link
Contributor Author

bartvanandel commented May 15, 2025

We will also need to look at deprecating the --order-by-popularity option, as this is essentially duplicated by --order-by="popularity"

Makes sense I guess.

If you don't mind, I won't be making any more changes. This PR is almost 7 years old and was essentially ignored for the past 5 years. I rebased once or twice on request, only to be left out in the cold again.

You're more than welcome to continue working on this branch though.

FWIW, the string "Available in 0.10.12+" is no longer valid either.

@gep13
Copy link
Member

gep13 commented May 15, 2025

@bartvanandel completely understood. Thank you again for getting this PR started, and apologies for the length of time taken.

The wheels turn slowly, but they do turn! 😄

@gep13 gep13 added this to the 2.5.0 milestone Jun 11, 2025
@AdmiringWorm AdmiringWorm force-pushed the feat/order-by-parameter branch from ad029bf to c973666 Compare June 19, 2025 13:25
@AdmiringWorm AdmiringWorm changed the title (#256) Add order-by parameter and sort packages by name by default (#3709) Add order-by parameter and sort packages by name by default Jun 19, 2025
@AdmiringWorm AdmiringWorm changed the title (#3709) Add order-by parameter and sort packages by name by default (#3709) Add support for ordering strategies using a new --order-by argument on the search command Jun 19, 2025
@AdmiringWorm AdmiringWorm requested a review from gep13 June 19, 2025 13:27
@AdmiringWorm AdmiringWorm changed the base branch from master to develop June 19, 2025 13:29
@AdmiringWorm AdmiringWorm force-pushed the feat/order-by-parameter branch from c973666 to eaa8030 Compare June 19, 2025 13:30
@AdmiringWorm
Copy link
Member

I have taken the liberty to update this PR to be compatible with the latest version of Chocolatey CLI, and rebased/retargeted it against develop.

@AdmiringWorm
Copy link
Member

I have updated the PR again, taking out the aliases and its related EnumExtension helper (I will move this to a different branch so we have a reference to it if needed in the future).

I have also wrapped all error and warning messages on column 80 as we discussed during our chat, and removed the prefixed Warning and Error since we aren't using that elsewhere in the codebase.

Add some more unit tests for the private methods that were added...

@AdmiringWorm AdmiringWorm force-pushed the feat/order-by-parameter branch from a436c00 to fd5e410 Compare June 20, 2025 14:23
Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit picks.

@AdmiringWorm AdmiringWorm force-pushed the feat/order-by-parameter branch from fd5e410 to 576a2c2 Compare June 20, 2025 16:01
bartvanandel and others added 2 commits June 20, 2025 17:13
Introduce a new 'order-by' option to the Chocolatey search command,
allowing users to sort package results by various criteria such as
Popularity, in addition to the default Id sorting. This replaces the
deprecated 'order-by-popularity' flag, which now logs a warning and
redirects users to the new option.

Add a PackageOrder enum to define valid sorting options and update
ListCommandConfiguration to use this enum for ordering. Mark the old
OrderByPopularity property as obsolete to guide migration.

These changes improve search flexibility and prepare for future
removal of deprecated options while maintaining backward compatibility.
Add explicit support for the --order-by option in Chocolatey tab
completion by introducing Get-ChocoOrderByOptions, which returns the
canonical order-by values. Update the search command to accept an
explicit --order-by parameter instead of a fixed --order-by-popularity.

This change improves flexibility and accuracy of tab completion for
the --order-by argument, aligning completions with Chocolatey's enum
values and enabling users to discover valid sorting options interactively.
@gep13 gep13 force-pushed the feat/order-by-parameter branch from 576a2c2 to 3a36bc8 Compare June 20, 2025 16:14
Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gep13 gep13 dismissed ferventcoder’s stale review June 20, 2025 16:15

This PR has moved on this the last review from Rob, and approval is no longer required.

@gep13
Copy link
Member

gep13 commented Jun 20, 2025

@bartvanandel thanks again for getting this PR started, we really appreicate it!

Once the CI builds are complete here, I am going to get this merged, and this will be shipping as part of Chocolatey CLI 2.5.0.

@gep13 gep13 merged commit 990e2d7 into chocolatey:develop Jun 20, 2025
5 checks passed
@gep13
Copy link
Member

gep13 commented Jul 1, 2025

Removing this from the 2.5.0 milestone, since the issue associated with it has been added to the milestone.

@gep13 gep13 removed this from the 2.5.0 milestone Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add --order-by option to choco search command to extend ability to order package results
5 participants