open_places 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbebad560b15e873b6c3d372093c029674815b75
4
- data.tar.gz: a0fce46a7ed62944e0293e6dcb5c54a03498b447
3
+ metadata.gz: 3ec524fc7eed7c33638c7c6021d2f02a04e6288d
4
+ data.tar.gz: 397e1c0c9fd649e3ae5ee1f2438afcb2adfc0f5c
5
5
  SHA512:
6
- metadata.gz: 49348b4d505f7ab91bbdc8b62335fe288b7b420a56e3298dce3fba4898200956b33277204ce84c035c78688e696344a54bf1b211c02c6525b2667e54f95c3e1f
7
- data.tar.gz: 2410e34d18c676298390ac7ae6bbcf77bba88714a8bc3b655f07925a1f416f4ae9ca008d1d6ed81f95cc4106eb497511487d8657cb831df13d541bf79b03f720
6
+ metadata.gz: eda323608724ab9c9b470acffaf3c99e2699de8c8429a6d2e432ccea05044312cd8c2579a545faceff52027337d910e3a0916c4cea638579f4053448b15da509
7
+ data.tar.gz: 66bdee81e7c2e4d3bbe481c36b5a5afb83bdfdafd8c9d31efd88d6fa23cf719f7fc2ab6180d4733ff8fd4f1983099381672a24208c1d5a6232d16919d74134f9
@@ -9,9 +9,9 @@ module OpenPlaces
9
9
  op = (params.keys & ['q', 'like', 'contains', 'starts', 'ends']).flatten.shift
10
10
  @results = OpenPlaces::Geo
11
11
  @results = @results.where(geotype: params[:type].split(",").map{|t| "OpenPlaces::#{t}" }) if params[:type].present?
12
- @results = @results.order('scalerank ASC')
13
12
  @results = @results.autocomplete(query_string, op) if query_string.present?
14
13
  @results = @results.near(params[:near]) if params[:near].present?
14
+ @results = @results.order('scalerank ASC')
15
15
  @results = @results.limit(params[:limit])
16
16
 
17
17
  respond_to do |format|
@@ -27,7 +27,7 @@ module OpenPlaces
27
27
  return where("#{table_name}.#{field} = '#{string}'")
28
28
  elsif op == 'like'
29
29
  string = string.gsub(/\'/, "''").gsub(/\,/, "")
30
- return where("#{table_name}.tsvector @@ to_tsquery(replace(quote_literal('#{string}'), '\s', '&')||':*')").order("to_tsquery(replace(quote_literal('#{string}'), '\s', '&')||':*') DESC")
30
+ return where("#{table_name}.tsvector @@ to_tsquery(replace(quote_literal('#{string}'), '\s', '&')||':*') ").order("similarity(#{table_name}.name, '#{string}') DESC, ts_rank(tsvector, to_tsquery(replace(quote_literal('#{string}'), ' ', '&')||':*')) DESC")
31
31
  elsif op == 'starts'
32
32
  return where("#{table_name}.#{field} LIKE '#{string}%'")
33
33
  elsif op == 'ends'
@@ -1,6 +1,7 @@
1
1
  class CreateOpenPlaces < ActiveRecord::Migration
2
2
  def up
3
3
  ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS postgis;")
4
+ ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm;")
4
5
  create_table(:open_places) do |t|
5
6
  t.string :geotype
6
7
  t.string :subtype
@@ -1,3 +1,3 @@
1
1
  module OpenPlaces
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_places
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ty Rauber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-02 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails