Skip to content

Commit 263f793

Browse files
committed
Merge branch 'develop'
2 parents b22e9ee + f46d281 commit 263f793

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gem 'rails', '~> 5.0.2'
1212

1313
# Cortex-specific
1414
gem 'cortex-exceptions', '= 0.0.4'
15-
gem 'cortex-plugins-core', '= 0.12.3'
15+
gem 'cortex-plugins-core', '= 0.12.4'
1616

1717
# API
1818
gem 'grape', '~> 0.17'

Gemfile.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ GEM
136136
concurrent-ruby (1.0.5)
137137
connection_pool (2.2.1)
138138
cortex-exceptions (0.0.4)
139-
cortex-plugins-core (0.12.3)
139+
cortex-plugins-core (0.12.4)
140140
cells (~> 4.1)
141141
cells-haml (~> 0.0)
142142
cells-rails (~> 0.0)
@@ -172,7 +172,7 @@ GEM
172172
dotenv-rails (2.2.1)
173173
dotenv (= 2.2.1)
174174
railties (>= 3.2, < 5.2)
175-
down (2.4.3)
175+
down (2.5.1)
176176
elasticsearch (5.0.4)
177177
elasticsearch-api (= 5.0.4)
178178
elasticsearch-transport (= 5.0.4)
@@ -327,8 +327,9 @@ GEM
327327
json_spec (1.1.4)
328328
multi_json (~> 1.0)
329329
rspec (>= 2.0, < 4.0)
330-
jsonb_accessor (1.0.0.beta.4)
330+
jsonb_accessor (1.0.0.beta.6)
331331
activerecord (>= 5.0)
332+
activesupport (>= 5.0)
332333
pg (>= 0.18.1)
333334
kaminari (0.17.0)
334335
actionpack (>= 3.0.0)
@@ -618,7 +619,7 @@ DEPENDENCIES
618619
cells-rails (~> 0.0.7)
619620
codeclimate-test-reporter (~> 0.6)
620621
cortex-exceptions (= 0.0.4)
621-
cortex-plugins-core (= 0.12.3)
622+
cortex-plugins-core (= 0.12.4)
622623
database_cleaner (~> 1.5)
623624
deep_cloneable (~> 2.2.2)
624625
devise (~> 4.2.1)

app/models/concerns/searchable.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def range_search(field, type, q)
3535
def published_filter
3636
# Bring in documents based on Draft status, Published date met, or either: Expired date not yet met, or Expired date null
3737
[
38-
{bool: {should: [term_search(:draft, false)]}},
39-
{bool: {should: [range_search(:published_at, :lte, DateTime.now.to_s)]}},
40-
{bool: {should: [range_search(:expired_at, :gte, DateTime.now.to_s), {missing: { field: :expired_at }}]}}
38+
{bool: {must: [term_search(:draft, false)]}},
39+
{bool: {must: [range_search(:published_at, :lte, DateTime.now.to_s)]}},
40+
{bool: {should: [range_search(:expired_at, :gte, DateTime.now.to_s), {bool: {must_not: {exists: { field: :expired_at }}}}]}}
4141
]
4242
end
4343
end

app/models/concerns/searchable_post.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,25 @@ def search_with_params(params, tenant, published = nil)
9393
if author
9494
bool[:bool][:filter] << term_search(:author, author)
9595
end
96+
9697
if published
9798
bool[:bool][:filter] << published_filter
99+
search query: bool, sort: [{is_sticky: {order: 'desc'}, published_at: {order: 'desc'}}]
100+
else
101+
search query: bool
98102
end
99-
100-
search query: bool
101103
end
102104

103105
def show_all(tenant, published = nil)
104106
bool = {bool: {filter: [{term: {tenant_id: tenant.id}}]}}
105107

106108
if published
107109
bool[:bool][:filter] << published_filter
110+
search query: bool, sort: [{is_sticky: {order: 'desc'}, published_at: {order: 'desc'}}]
111+
else
112+
search query: bool, sort: [{is_sticky: {order: 'desc'}, created_at: {order: 'desc'}}]
108113
end
109114

110-
search query: bool, sort: [{is_sticky: {order: 'desc'}, created_at: {order: 'desc'}}]
111115
end
112116
end
113117
end

app/models/content_item.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def method_missing(*args)
113113
"#{publish_state.downcase}?" == args[0].to_s
114114
else
115115
# Used to query for any field on the relevant ContentType and return data from the content_item
116-
field_items.select { |field_item| field_item.field.name.parameterize({ separator: '_' }) == args[0].to_s }.first.data.values[0]
116+
field_items.select { |field_item| field_item.field.name.parameterize(separator: '_') == args[0].to_s }.first.data.values[0]
117117
end
118118
end
119119
end

app/models/content_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def self.permissions
2525
end
2626

2727
def content_items_index_name
28-
content_type_name_sanitized = name.parameterize('_')
28+
content_type_name_sanitized = name.parameterize(separator: '_')
2929
"#{Rails.env}_content_type_#{content_type_name_sanitized}_content_items"
3030
end
3131

0 commit comments

Comments
 (0)