I have two models
class Filters < ActiveRecord::Base
end
class Groups < ActiveRecord::Base
end
Filter model is responsible for fetching user data from db e.g
filter_id_1. SELECT users.* FROM users INNER JOIN notes ON notes.user_id = users.id WHERE notes.category = 'Emotions'
filter_id_2. SELECT users.* FROM users INNER JOIN subscriptions ON subscriptions.user_id = users.id WHERE (Date(end_date) = CURDATE())
filter_id_3. SELECT users.* FROM users WHERE (auth_token_created_at > DATE_SUB(NOW(), INTERVAL 2 hour))
Group model makes a group with multiple filters with AND and OR conditions e.g
group_id_1 = "filter_id_1 AND filter_id_2 OR filter_id_3"
Now using group I am trying to fetch users by converting expression to methods according to AND OR conditions.
users = Filter.find(1).get_users & Filter.find(2).get_users | Filter.find(3).get_users
How can i convert this experssion from this "filter_id_1 AND filter_id_2 OR filter_id_3"
to this
users = Filter.find(1).get_users & Filter.find(2).get_users | Filter.find(3).get_users
Aucun commentaire:
Enregistrer un commentaire