Adding feature to load and search cities according q, lat and long #8

Closed
wants to merge 14 commits into
from

Projects

None yet

2 participants

@jeromelefeuvre

No description provided.

jeromelefeuvre added some commits Feb 7, 2014
@jeromelefeuvre jeromelefeuvre Set ruby 2.0.0 in `Gemfile` 6adf986
@jeromelefeuvre jeromelefeuvre Add 'active_support' gem for parameterize query 9e9b449
@jeromelefeuvre jeromelefeuvre Add `geocoder` gem for calculate distance between points 3c0c305
@jeromelefeuvre jeromelefeuvre Add ParseDatas Class
This class permit to store cities files in an array for future search. All cities where population < ParseDatas::MAX_POPULATIONS are excluded
```
cities = ParseDatas.get_datas_from_csv(file_path)
```
b17a724
@jeromelefeuvre jeromelefeuvre Add Suggestion class
This class filter cities according parameters
`Suggestion.new(cities, params).results` return results sorted by name
14026b7
@jeromelefeuvre jeromelefeuvre Add score by length to `Suggestion`.
Here, We comparing the length of the query with the length of the city.
```
London/London = 1
Londo/London = 0.83
Londo/Londonderry = 0.41
```
e2e0c2b
@jeromelefeuvre jeromelefeuvre Change sorting of cities by score descending and by name ascending 0987611
@jeromelefeuvre jeromelefeuvre Add score by distance to `Suggestion`
Here we use `geocoder` gem for calculate distance (using Haversine formula) and transposed to a score between 0 and 1 with:
`1 - distance / (Math::PI*Geocoder::Calculations::EARTH_RADIUS)`
89defa7
@jeromelefeuvre jeromelefeuvre Add score by populations to `Suggestion`
Most of the time, users search big cities so cities with most populations had a better score than small cities
ad1bdd2
@jeromelefeuvre jeromelefeuvre Add `redis` gem f5526ce
@jeromelefeuvre jeromelefeuvre Configure redis 7ba0240
@jeromelefeuvre jeromelefeuvre Add limit parameter to `Suggestion` 220b793
@jeromelefeuvre jeromelefeuvre Add documentation 0e56f38
@cdnbacon
Contributor

@jeromelefeuvre Seems I can't run the specs locally, any idea why I might be getting this error after running the following commands?

bundle install
bundle exec rspec

Error

$ bundle exec rspec
/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis/client.rb:409:in `rescue in _parse_driver': Cannot load driver "hiredis" (RuntimeError)
    from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis/client.rb:405:in `_parse_driver'
    from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis/client.rb:376:in `_parse_options'
    from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis/client.rb:67:in `initialize'
    from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis.rb:31:in `new'
    from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis.rb:31:in `initialize'
    from /jerome-lefeuvre/coding-challenge-backend-b/app.rb:19:in `new'
    from /jerome-lefeuvre/coding-challenge-backend-b/app.rb:19:in `block in <class:App>'
    from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sinatra-1.4.4/lib/sinatra/base.rb:1393:in `configure'
        ...
@jeromelefeuvre

oh you right, seems I forgot to run tests after configured Redis. My next commit fix that, sorry !

@cdnbacon cdnbacon closed this Feb 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment