vrfs-775: added new_musicians method and test
This commit is contained in:
parent
a8f68c6396
commit
b1b2a2e360
|
|
@ -247,5 +247,19 @@ module JamRuby
|
|||
false
|
||||
end
|
||||
|
||||
def self.new_musicians(since_date=Time.now - 1.week, max_count=100, radius=500)
|
||||
return unless block_given?
|
||||
User.where(['lat IS NOT NULL AND lng IS NOT NULL']).find_each do |usr|
|
||||
rel = User.where(:musician => true)
|
||||
.where(['created_at >= ? AND users.id != ?', since_date, usr.id])
|
||||
.within(radius, :origin => [usr.lat, usr.lng])
|
||||
.order('created_at DESC')
|
||||
.limit(max_count)
|
||||
if 0 < rel.count
|
||||
yield rel
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -168,4 +168,10 @@ describe User do
|
|||
results.musicians.count.should == User.count
|
||||
end
|
||||
|
||||
it "should find new musicians nearby" do
|
||||
Search.new_musicians do |usrs|
|
||||
usrs.count.should.not == 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue