Skip to content
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

Merged
merged 6 commits into from
Jan 17, 2018
Merged

API for nearby node fetching #1987

merged 6 commits into from
Jan 17, 2018

Conversation

grvsachdeva
Copy link
Member

Fixes #1934

@PublicLabBot
Copy link

PublicLabBot commented Jan 13, 2018

2 Messages
📖 @Gauravano Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.
📖 This pull request doesn’t link to a issue number. Please refer to the issue it fixes (if any) in the body of your PR, in the format: Fixes #123.

Generated by 🚫 Danger

Copy link
Member

@jywarren jywarren left a 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

@grvsachdeva
Copy link
Member Author

grvsachdeva commented Jan 13, 2018

Testing is always good.will add tests...Thanks, Jeff.

@grvsachdeva
Copy link
Member Author

grvsachdeva commented Jan 16, 2018

Hey, @sagarpreet-chadha I have updated the items object so latitude and longitude would be available now.

update

@jywarren
Copy link
Member

Hi, just a note - can we also specify in a field if location:blurred so we know whether people are sharing an exact location or a low-res one? Thank you!

@grvsachdeva
Copy link
Member Author

@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 ?

@sagarpreet-chadha
Copy link
Contributor

Hi @Gauravano , i think if node contains tag location:blurred , the node is sharing low-res location . What do you think ? Thanks 😄 !

@grvsachdeva
Copy link
Member Author

Yes @sagarpreet-chadha it makes sense.Thanks

@grvsachdeva
Copy link
Member Author

@jywarren the first part of the issue is completed by me, plz review it.

@@ -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)
Copy link
Member

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!

Copy link
Member Author

Choose a reason for hiding this comment

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

correcting this..

@@ -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"}
Copy link
Member

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)

Copy link
Member Author

@grvsachdeva grvsachdeva Jan 17, 2018

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

@@ -183,4 +183,37 @@ def textSearch_questions(srchString)
end
sresult
end

#Search nearby nodes with respect to given latitude and longitude
Copy link
Member

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!

Copy link
Member Author

Choose a reason for hiding this comment

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

No problem at all

.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|
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

This is super. 🎉

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Jeff

@grvsachdeva
Copy link
Member Author

@jywarren plz review it.Thanks.

@jywarren jywarren merged commit 8e1a7a0 into publiclab:master Jan 17, 2018
@jywarren
Copy link
Member

🎉 🎈 👍 💥

SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this pull request May 5, 2019
* function added

* initiated test

* latitude and longitude added in items

* location blurred or not added

* Functional test added

* Small changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants