-
Notifications
You must be signed in to change notification settings - Fork 929
(#3709) Add support for ordering strategies using a new --order-by
argument on the search command
#1619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(#3709) Add support for ordering strategies using a new --order-by
argument on the search command
#1619
Conversation
src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
Minor nitpick, the git commit body (the message) needs to split at 72/80 characters as well. |
Do you want 72 or 80? |
72 is what CONTRIBUTING states - |
bd1f31a
to
6412eaf
Compare
Wrapped commit body at 72 chars as requested. |
6412eaf
to
47c339c
Compare
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? |
@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. |
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? |
@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. |
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. |
@ferventcoder any progress on this PR? |
@ferventcoder hello? |
@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... |
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. |
@ferventcoder Any chance this PR is ever going to be merged? I just ran 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. |
@gep13 Are you the new maintainer? Would you be willing to finish up and merge this long-standing pull request? |
I give up. For more than 3 I've tried to get this PR reviewed and merged, but @ferventcoder doesn't seem interested enough. |
order-by
parameter and sort packages by name by defaultorder-by
parameter and sort packages by name by default
We will also need to look at deprecating the |
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. |
@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! 😄 |
ad029bf
to
c973666
Compare
order-by
parameter and sort packages by name by defaultorder-by
parameter and sort packages by name by default
order-by
parameter and sort packages by name by default--order-by
argument on the search command
c973666
to
eaa8030
Compare
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. |
src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs
Outdated
Show resolved
Hide resolved
src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs
Outdated
Show resolved
Hide resolved
eaa8030
to
fbd1608
Compare
fbd1608
to
a436c00
Compare
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 Add some more unit tests for the private methods that were added... |
a436c00
to
fd5e410
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit picks.
src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs
Outdated
Show resolved
Hide resolved
src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs
Outdated
Show resolved
Hide resolved
fd5e410
to
576a2c2
Compare
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.
576a2c2
to
3a36bc8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR has moved on this the last review from Rob, and approval is no longer required.
@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. |
Removing this from the 2.5.0 milestone, since the issue associated with it has been added to the milestone. |
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.
choco search chrome --order-by='id'
--order-by='title'
choco-protocol-support
(It is prefixed with(unofficial)
in the title, and is expected to be the first result in this case.--order-by='popularity'
GoogleChrome
).--order-by='unsorted'
chrome
in the search box and hit enter.--order-by='LastPublished'
.Order By 'LastPublished' has been specified. This order is done on client side and may lead to inconsistently ordered results.
Recent
.--order-by='other'
.Error: The order-by clause 'other' is not recognized. Use one of the supported clauses: 'Id', 'LastPublished', 'Popularity', 'Title', 'Unsorted'.
.Operating Systems Testing
Change Types Made
Change Checklist
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