Search over contributors #115

This needs some refactoring, but please take a look.  
Yes, but it seems to run pretty quickly, we don’t really have all that much data.  If necessary we can add a field that contains the lower case version of the name which would run faster.
I don’t think we can require people to enter people’s full name, which would permit an indexed search.  

On Aug 27, 2014, at 9:05 PM, Tom Dooner <notifications@github.com> wrote:

> In app.rb:
> 
> > @@ -49,6 +49,25 @@ class << self
> >        .includes(:contributor, :recipient).to_json(fields)
> >    end
> >  
> > +  get '/api/contributorName/:name' do |name|
> > +    cache_control :public
> > +    last_modified Import.last.import_time
> > +
> > +    headers 'Content-Type' => 'application/json'
> > +
> > +    fields = {
> > +      include: [
> > +        { recipient: { methods: :short_name } },
> > +        { contributor: { methods: :short_name } },
> > +      ],
> > +    }
> > +    search 	  = "%" + name.downcase + "%"
> > +    party         = Party.where("lower(name) like ?", search)
> Ouch, our poor poor database.
> 
> —
> Reply to this email directly or view it on GitHub.
>