Search over contributors #115

This needs some refactoring, but please take a look.  
yes but, an interesting query is “police” which is neither a first name or last name.
We could have a table with each word in the name field that links to the parties table if its an issue.

On Aug 27, 2014, at 10:07 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)
> Well, if we stored lower(first name) and lower(last name) we could just do a prefix search, because people will start typing names from the beginning anyway.
> 
> But yeah, I think we should be fine since we only have 6247 Partys to search through.
> 
> —
> Reply to this email directly or view it on GitHub.
>