tkwidmer/refugerestrooms — pull request #85 by f3ndot (2014-03-15 04:07:40+00:00)
Title: Basic, public API for listing and full-text searching bathrooms

Hi all,

I've written a basic API to help more technically savvy users and app developers better use the data. This is a basic API implementation, so there's no auth (yet) and nothing to let a user submit, update, or destroy records. All it does for now is list and search records.

The search is implemented using PostgreSQL's full-text search functionality. This is amazing stuff! Using the `pg_search` gem, I basically told the database I want to search `name`, `city`, `directions`, `comments`, etc. with associated weights on each one. I even told it to ignore accents (eg searching `café` will find `cafe`). With the tsearch English dictionary chosen, it's smart enough to know pluralization and ignore things like `of` and `the` in the search. Quite outstanding stuff!

The API has automated docs generation using the `grape-swagger` gem. It's UI can be seen below:

![screen shot 2014-03-15 at 12 01 28 am](https://f.cloud.github.com/assets/740289/2427593/179d043c-abf7-11e3-94dd-05345f64d1ec.png)

You can see the relative weights I've assigned to the text in e19ad6075db325469b5dc985025314aa3f70f44a where `A` is more important than `D`. Let me know what you think of those weight choices.