ref: master
plugins/sniffer/lib/ext/article.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
require_dependency 'article' class Article # search for interests of interested that matches the knowledges of wise scope :sniffer_plugin_knowledges_interests, lambda { |wise, interested| { select: "op.opportunity_id AS interest_cat, articles.name AS knowledge_name, articles.id AS id, article_resources.resource_id AS knowledge_cat", joins: "INNER JOIN article_resources ON (articles.id = article_resources.article_id) INNER JOIN sniffer_plugin_opportunities AS op ON (article_resources.resource_id = op.opportunity_id AND article_resources.resource_type = 'ProductCategory' AND op.opportunity_type = 'ProductCategory') INNER JOIN profiles sniffer ON op.profile_id = sniffer.id", conditions: "articles.type = 'CmsLearningPlugin::Learning' AND articles.profile_id = #{wise.id} AND sniffer.id = #{interested.id}" } } end |