I have a query that involves 4 inner joins, the only reason I want to
use it with TS is so that I can incorporate a geospatial search.
Basically, every time a user posts with a tag, a delayed job will find
everyone who is subscribed to that tag within a certain radius and
then send out an email.
Here is what will generate my recipient list in ActiveRecord minus the
geospatial part. (It will also run in a delayed job task)
# SELECT DISTINCT users.id, users.email
# => FROM `users`
# => INNER JOIN `user_tag_subscriptions` ON
`user_tag_subscriptions`.`user_id` = `users`.`id`
# => INNER JOIN `tags` ON `tags`.`id` =
`user_tag_subscriptions`.`tag_id`
# => INNER JOIN `post_tags` ON `post_tags`.`tag_id` =
`tags`.`id`
# => WHERE `post_tags`.`post_id` = 123"
@recipients = User.joins(:user_tag_subscriptions => [:tag
=> :post_tags])
.where('post_tags.post_id' => 123)
.select("DISTINCT users.id, users.email")
LAT/LON data is nested in the UserTagSubscription object. It has a
user_id, tag_id, location_id. The Location object has the actual LAT/
LON coordinates.
Is this possible using TS?
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.