-
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
API for nearby node fetching #1987
Conversation
Generated by 🚫 Danger |
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 looking great. What about a functional test for it? Good idea?
https://github.com/publiclab/plots2/blob/master/test/functional/search_api_test.rb
Testing is always good.will add tests...Thanks, Jeff. |
Hey, @sagarpreet-chadha I have updated the items object so latitude and longitude would be available now. |
Hi, just a note - can we also specify in a field if |
@jywarren could you please elaborate on what factors we can term location as blurred ? Is it related to latitude and longitude entered (srchString=lat,lon) that if lat=24.68 i.e.,2 digits after decimal then it is termed as blurred location ? |
Hi @Gauravano , i think if node contains tag |
Yes @sagarpreet-chadha it makes sense.Thanks |
@jywarren the first part of the issue is completed by me, plz review it. |
app/models/doc_result.rb
Outdated
@@ -15,6 +15,20 @@ def self.fromSearch(idval, typeval, urlval, titleval, sumval, scoreval) | |||
obj | |||
end | |||
|
|||
def self.fromLocationSearch(idval, typeval, urlval, titleval, sumval, scoreval,latitude,longitude,blurred) |
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, just wondering if we could tidy up the spacing towards the end of this line, and on lines 41-2 below. This really helps keep the code tidy over the long term, 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.
correcting this..
app/models/doc_result.rb
Outdated
@@ -24,5 +38,7 @@ class Entity < Grape::Entity | |||
expose :docTitle, documentation: { type: 'String', desc: 'Title or primary descriptor of the linked result.' } | |||
expose :docSummary, documentation: { type: 'String', desc: 'If available, first paragraph or descriptor of the linked document.' } | |||
expose :docScore, documentation: { type: 'Float', desc: "If calculated, the relevance of the document result to the search request; i.e. the 'matching score'" } | |||
expose :latitude, documentation: {type: 'String',desc: "Returns the latitude associated with node"} | |||
expose :longitude, documentation: {type: 'String',desc: "Returns the longitude associated with node"} |
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.
Here, should it be "Float"? Or is it String because we want to preserve the # of significant digits? (the latter makes sense to me... just want to be sure)
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.
yes Jeff Latitude and Longitude is stored in DB as String any manipulation in data type can lead to a change in no. of significant digits
app/services/search_service.rb
Outdated
@@ -183,4 +183,37 @@ def textSearch_questions(srchString) | |||
end | |||
sresult | |||
end | |||
|
|||
#Search nearby nodes with respect to given latitude and longitude |
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.
I /think/ this needs a space between the #
and S
to be recognized by the auto API generator which I've been testing in another PR. Sorry to be so detail-oriented!
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.
No problem at all
app/services/search_service.rb
Outdated
.where('node.nid IN (?) AND term_data.name LIKE ?', nids, 'lon:' + lon[0..lon.length - 2] + '%') | ||
.limit(200) | ||
.order('node.nid DESC') | ||
items.each do |match| |
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.
And here maybe slightly better indentation plus spaces around the =
on line 206, 208 would be really great.
Thanks again for all your hard work! This is going to be great.
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.
Correcting..
@@ -10,6 +10,7 @@ Per-model API endpoints are: | |||
* Questions: https://publiclab.org/api/srch/questions?srchString=foo | |||
* Tags: https://publiclab.org/api/srch/tags?srchString=foo | |||
* Notes: https://publiclab.org/api/srch/notes?srchString=foo | |||
* Locations: https://publiclab.org/api/srch/locations?srchString=lat,lon |
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.
Awesome
|
||
end | ||
|
||
test 'search nearby nodes functionality' 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.
This is super. 🎉
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.
Thanks Jeff
@jywarren plz review it.Thanks. |
🎉 🎈 👍 💥 |
* function added * initiated test * latitude and longitude added in items * location blurred or not added * Functional test added * Small changes
Fixes #1934