Create links on /search/_____ for search sorting options
Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.
If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!
If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!
The problem
It's not easy to switch search sorting order among the available options:
- https://publiclab.org/search/pumpkins?order=natural for natural language match ordering
- https://publiclab.org/search/pumpkins?order=likes for ordering by likes
- https://publiclab.org/search/pumpkins?order=views for ordering by views
- https://publiclab.org/search/pumpkins for ordering by original page creation dates
Solution
Create links (such as the 4 options above) at the top of the search page to order results by the following possibilities. (of course replacing "pumkpin" with the actual search term)
So when you arrive at https://publiclab.org/search/pumpkins, you can then click to get to any other type of sorting, as above.
Mockup screenshot:

These links should go below this line on the searches results.html.erb template:
https://github.com/publiclab/plots2/blob/ea2b5ba1ded2b23a156091cd0add5df9234ae650/app/views/searches/results.html.erb#L3-L4
Steps to Fix
- [ ] claim this issue with a comment here, below, and ask any clarifying questions you need
- [ ] set up a repository locally following the README instructions, and make sure that all tests pass
- [ ] try to fix the issue following the steps above, but even before you're done, you can:
- [ ] commit your changes and start a pull request (see contributing to Public Lab software) but mark it as "in progress" if you have questions or if you haven't finished
- [ ] alert someone via the developers list (see below) to have your pull request merged. This may take a few extra steps depending on when you do it, but we'll help you out!
Please email the developers list (see https://publiclab.org/wiki/developers) or go to the chatroom if you have questions, and take a look at our first-timers landing page!
(This issue broken out from https://github.com/publiclab/plots2/issues/2421)
Follow-up (or extra)
- [ ] Set the default ordering for results shown on https://publiclab.org/search/keyword to be by "natural language match" instead of the current default.
@publiclab/reviewers Would anyone like to create a First Timers Only issue out of this? Hope you are having a wonderful day!
Hi, can I claim this issue? It's my first time contributing, but I think I know how to do it.
@pnowacki90 Yeah sure go for it.
Hi @pnowacki90 you can have this issue. Please let me know if you'll need some help :)
@siaw23 Ok, I have a problem. I can't verify if everything is fine, the search doesn't work. If I try to search for anything on my local machine I get an error:
ArgumentError (wrong number of arguments (given 0, expected 1)):
app/models/node.rb:46:in 'search'
app/services/typeahead_service.rb:51:in 'nodes'
app/controllers/searches_controller.rb:19:in 'results'
Also when I run rake test I get a bunch of errors.
OK! Let me pull the latest build and see if I can reproduce locally. I will get back to you later today @pnowacki90
hi @pnowacki90, can you please make the following temporal change to allow you to continue with this issue: https://gist.github.com/siaw23/08910f4c2ce2780f43c070e349bab1d3
looks like i have to create a separate issue for this, something is messed up somewhere.
hi @siaw23 , could you take a look at my pull request? I may have messed something up. I commited relevant changes to results view and to node model
@pnowacki90 fellow newbie here, has this been resolved?
Hi @chanjess I think this is available unless @pnowacki90 is still able to work on it -- i'm sorry, it looks like @pnowacki90 made a lot of progress but got stuck on a test. I'm trying to help untangle that now, but it could be a matter of building a bit on that PR to complete it!
I'm sorry, I just started a new job and I won't be able to finish this issue in near future. @chanjess if you're still interested, give it a go
Thanks, @pnowacki90 -- and @chanjess if you'd like to pick up where @pnowacki90 left off, the PR is here: https://github.com/publiclab/plots2/pull/2584 - it's pretty close!
Thanks all!
Hi, all, i think this is still available if anyone is interested! Thank you!
Hello @jywarren I've just made a PR for this issue. Thanks
Solved by @gSanchezCiarrocchi !! Thank you!!!