Popular protips Mailer

Create new search with a mailer to send a monthly email highlighting the popular protips for the past month.
It's an easy query and we are dumping Tire. This works without any special framework, it runs once a month, and bypasses a ton of search related junk.

Sent from my iPhone

> On Aug 26, 2014, at 3:35 PM, Abdelkader Boudih <notifications@github.com> wrote:
> 
> In app/mailers/protip_mailer.rb:
> 
> > +
> > +  def teams_for_user(user)
> > +    Team.most_relevant_featured_for(user).select do |team|
> > +      team.hiring?
> > +    end
> > +  end
> > +
> > +  module Queries
> > +    def self.popular_protips(from, to)
> > +      search_results = ProtipMailer::Queries.search_for_popular_protips(from, to)
> > +      public_ids = search_results.map { |protip| protip['public_id'] }
> > +
> > +      Protip.eager_load(:user, :comments).where('public_id in (?)', public_ids)
> > +    end
> > +
> > +    def self.search_for_popular_protips(from, to, max_results=10)
>  Use Tire! you can pass the hash to the search .
> 
> —
> Reply to this email directly or view it on GitHub.