Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
grvsachdeva committed Jan 17, 2018
1 parent f3cf939 commit 46f3d43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions app/models/doc_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.fromSearch(idval, typeval, urlval, titleval, sumval, scoreval)
obj
end

def self.fromLocationSearch(idval, typeval, urlval, titleval, sumval, scoreval,latitude,longitude,blurred)
def self.fromLocationSearch(idval, typeval, urlval, titleval, sumval, scoreval, latitude, longitude, blurred)
obj = new
obj.docId = idval
obj.docType = typeval
Expand All @@ -38,7 +38,8 @@ 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"}
expose :latitude, documentation: { type: 'String', desc: "Returns the latitude associated with the node." }
expose :longitude, documentation: { type: 'String', desc: "Returns the longitude associated with the node." }
end

end
15 changes: 9 additions & 6 deletions app/services/search_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def textSearch_questions(srchString)
sresult
end

#Search nearby nodes with respect to given latitude and longitude
# Search nearby nodes with respect to given latitude and longitude
def nearbyNodes(srchString)
sresult = DocList.new
coordinates = srchString.split(",")
Expand All @@ -202,15 +202,18 @@ def nearbyNodes(srchString)
.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|
blurred=false

items.each do |match|
blurred = false

match.node_tags.each do |tag|
if tag.name=="location:blurred"
blurred=true
if tag.name == "location:blurred"
blurred = true
break
end
end
doc = DocResult.fromLocationSearch(match.nid, 'coordinates', match.path(:items), match.title, 0, match.answers.length.to_i,match.lat,match.lon,blurred)

doc = DocResult.fromLocationSearch(match.nid, 'coordinates', match.path(:items), match.title, 0, match.answers.length.to_i, match.lat, match.lon, blurred)
sresult.addDoc(doc)
end
sresult
Expand Down

0 comments on commit 46f3d43

Please sign in to comment.