Skip to content

Fixed the hard coded sorting for profiles search #10693

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

Closed

Conversation

johnmarkstrickland
Copy link

@johnmarkstrickland johnmarkstrickland commented Feb 5, 2022

The profile search was hard coded to perform only one type of sorting, so I removed that hard code in the controller and added in getting the users choice from the parameters.

Fixes #9334

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • [✅] PR is descriptively titled 📑 and links the original issue above 🔗
  • [ ✅] tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • [✅ ] code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

@welcome
Copy link

welcome bot commented Feb 5, 2022

Thanks for opening this pull request! This space is protected by our Code of Conduct - and we're here to help.
Dangerbot will test out your code and reply in a bit with some pointers and requests.
Also please refer here for installation help 💿
There may be some errors, but don't worry! We'll work through them with you! 👍🎉😄


One thing that can help to get started is to make sure you've included a link back to the original issue you're solving, in the format fixes #0000 (for example). And to make sure the PR title describes what you're trying to do! (often it can be the same as the issue title) Thanks! 🙌


Then, you can say hello in our chatroom & share a link to this PR to get a review! 👋 ✅

@gitpod-io
Copy link

gitpod-io bot commented Feb 5, 2022

@codecov
Copy link

codecov bot commented Feb 5, 2022

Codecov Report

Merging #10693 (ca27d6d) into main (4d31f1d) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #10693      +/-   ##
==========================================
+ Coverage   82.43%   82.45%   +0.01%     
==========================================
  Files          98       98              
  Lines        5990     5996       +6     
==========================================
+ Hits         4938     4944       +6     
  Misses       1052     1052              
Impacted Files Coverage Δ
app/controllers/search_controller.rb 97.67% <100.00%> (ø)
app/services/search_service.rb 95.19% <100.00%> (+0.29%) ⬆️

@github-actions
Copy link

github-actions bot commented Feb 5, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5189402947/artifacts/157954797

@github-actions
Copy link

github-actions bot commented Feb 5, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5189519584/artifacts/157962294

user_scope.joins(:revisions)
.where("node_revisions.status = 1")
.order("node_revisions.timestamp #{search_criteria.order_direction}")
user_scope.joins(:revisions)
Copy link

Choose a reason for hiding this comment

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

Use 2 (not 0) spaces for indentation.

@github-actions
Copy link

github-actions bot commented Feb 5, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5190655217/artifacts/158045944

@github-actions
Copy link

github-actions bot commented Feb 6, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5194557821/artifacts/158330321

@TildaDares
Copy link
Member

Hi @jstrickl-tunes, do you think you could add functional tests for this feature? Take a look at some test examples you can use as a guide

test 'search profiles by username without order_by and default sort_direction' do
get '/api/srch/profiles?query=steff&field=username'
assert last_response.ok?
# Expected search pattern
pattern = {
srchParams: {
query: 'steff',
seq: nil,
}.ignore_extra_keys!
}.ignore_extra_keys!
matcher = JsonExpressions::Matcher.new(pattern)
json = JSON.parse(last_response.body)
assert_equal "/profile/steff3", json['items'][0]['doc_url']
assert_equal "/profile/steff2", json['items'][1]['doc_url']
assert_equal "/profile/steff1", json['items'][2]['doc_url']
assert matcher =~ json
end

Great job!!

@github-actions
Copy link

github-actions bot commented Mar 4, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5537179448/artifacts/178094266

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5547966918/artifacts/178779847

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5548259001/artifacts/178798728

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5548398012/artifacts/178807528

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5551085237/artifacts/178997371

@codeclimate
Copy link

codeclimate bot commented Mar 6, 2022

Code Climate has analyzed commit ca27d6d and detected 0 issues on this pull request.

View more on Code Climate.

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/5551179721/artifacts/179003940

@stale
Copy link

stale bot commented Mar 11, 2023

Hi 😄, this issue has been automatically marked as stale because it has not had recent activity. Don't worry you can continue to work on this and ask @publiclab/reviewers to add in-progress label 🎉 . Otherwise, it will be closed if no further activity occurs in 10 days -- but you can always re-open it if you like! 💯 Thank you for your contributions! 🙌 🎈.

@stale stale bot added the stale label Mar 11, 2023
@stale stale bot closed this Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sorting is not working in the search/profiles page
2 participants