-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Remove API Search endpoints duplication #3045
Conversation
Hi, this is due to a new check that was added recently to encourage very consistent formatting. I've actually turned off the check until we can make it's output friendlier, but since your work is based on an earlier version of code, you're seeing some formatting suggestions. You can resolve them by going through them one by one here: https://travis-ci.org/publiclab/plots2/builds/402502945#L3400 Sorry, it's a bit obscure, we're working to make this more readable!!! Thanks! |
2b32937
to
8dc4729
Compare
Generated by 🚫 Danger |
Cool! got the tests to pass, i see! Now, CodeClimate is complaining about "cognitive complexity" -- basically, asking you to try to simplify how the code is written in order to make it more readable. CodeClimate is picky -- any time you think it's being too particular, you can ping me and I can manually "approve" a PR and we can move forward -- not a problem! But if you click "details" next to CodeClimate, it'll offer some advice: https://codeclimate.com/github/publiclab/plots2/pull/3045 If you hover over the right-side of each issue, it has a "read more" link which offers some tips on how to resolve it: These are actually really nice and helpful despite the For this one, I'm OK with how you've done it. If you'd like, I can just approve it -- just tell me what you think! Actually, what I just wrote in this comment is a nice thing we could add to a README in the repository... what do you think? I'd accept a PR with this text in a Thanks! |
@mridulnagpal is working on CodeClimate on his own project and may find this interesting! |
HI, Jeff! Yeah, sorry, I forgot to tell that we fixed the small issues. I didn't say anything because we are still working on this. We are breaking the responsibilities into new classes so we may fix that issue. Just having a little problem trying to understand a Grape error for now! :P And great idea about the codeclimate.md file! We can start that for sure :) |
Hey @jywarren, today we worked on our code to remove cognitive complexity from the Search API. We still have to work on minor repairs, but we'll do it tomorrow! |
Hey @jywarren, it looks like all checks have passed now! |
@publiclab/soc @publiclab/reviewers hey, everyone, just one question regarding the Typeahead Service.
We run the tests and searched locally the API and we couldn't see any difference in the sresult list between using that or removing it. Can someone please explain more about this? Thank you! |
Hmm, I'm not sure about that either, but can try to trace through the code to figure it out. Can you find documentation for the |
Hi @stefannibrasil ... Line 28 in 40a207b
In comments above this internal-class is written : Hope it helps ! |
Hey @jywarren, @stefannibrasil's question ( |
@milaaraujo is right! We are waiting for the review of this PR before opening the Typeahead refactor proposal. We did the same thing as we did here with the Search. While this one isn't approved, I decided to ask about the Typeahead service. This is the line that I was referring to (we can continue the discussion after this current PR is reviewed/approved): plots2/app/api/srch/typeahead.rb Line 27 in 40a207b
We wanted to understand why Typeahead adds that to each endpoint call. If we remove it, we don't see any difference in the results format, so we don't understand what exactly that line is supposed to do. @sagarpreet-chadha do you have an idea why only typeahead use that? the search service doesn't use the DocList::Entity 🤔 And even if we remove that line, we still get the results as a list:
so there is no apparent difference between using that or not. The result is already a TagList. I have a guess that we don't need that at all, but we wanted to know what do you think 💭 |
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.
This is awesome, i love it. Great work on breaking into separate files. I asked for a couple extra comments to help orient people who aren't familiar with how the files are split up. Then I think we're good!
test/functional/search_api_test.rb
Outdated
@@ -166,29 +211,4 @@ def app | |||
|
|||
end | |||
|
|||
test 'search recent people functionality having specified tagName' do |
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.
Did you remove this because it's covered by the all
test? Just checking!
app/api/srch/search.rb
Outdated
@@ -3,6 +3,8 @@ | |||
|
|||
module Srch | |||
class Search < Grape::API | |||
helpers SharedParams |
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.
Should we write a comment like # see /app/api/srch/shared_params.rb
?
extend Grape::API::Helpers | ||
|
||
params :common do | ||
requires :srchString, type: String, documentation: { example: 'Spec' } |
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.
This is fantastic. Thanks!!!
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.
@jywarren we added the test back. We'll probably work more on the tests in the next weeks, but just to be more careful, we think it's best to not remove it for now. Good catch!
we've already done the same strategy here in the Typeahead, we are planning to open a PR for that after this is approved!
Thanks! 💯
32bb9cd
to
ac12304
Compare
ac12304
to
5b8bcb7
Compare
Hi guys, I'm adding a last modification - I hope so! - to the code.
|
I think the error we're seeing may have been resolved in another PR - so you should be able to rebase your work over the latest master and it should disappear. However I've restarted the build to see if it "resolves itself" first... you can always re-run Travis tests by closing and reopening the PR. You can rebase by following the process outlined here, but you may be able to skip step 2 if your master is still in sync with publiclab's master: https://publiclab.org/wiki/contributing-to-public-lab-software#Rewinding+the+master+branch Thanks! |
It passed now, @jywarren! |
Hooray!!!! 🎉 🎉 🎉 |
* WIP - Remove API Search enpoints duplication * Remove cognitive complexity from Search api * Changes requested and clodeclimate fixes * Adding limit=srchString to recentPeople method
Hello, everyone!
We are opening this PR to get some feedback about our work with the API.
In order to refactor how the searches are being made, we decided to first try to remove some duplications. We have done some small changes but we wanted to know what do you think and see if there is another thing we can remove/change.
@publiclab/reviewers @publiclab/soc @jywarren