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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec524fc7eed7c33638c7c6021d2f02a04e6288d
|
4
|
+
data.tar.gz: 397e1c0c9fd649e3ae5ee1f2438afcb2adfc0f5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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}'), '
|
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
|
data/lib/open_places/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|