From b623ece799a8208e80af57d29d7c16a17b462462 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Mon, 8 May 2017 11:28:51 -0500 Subject: [PATCH 1/4] fix: parameterize deprecation warning --- app/models/content_item.rb | 2 +- app/models/content_type.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/content_item.rb b/app/models/content_item.rb index f40017e91..3a2117360 100644 --- a/app/models/content_item.rb +++ b/app/models/content_item.rb @@ -113,7 +113,7 @@ def method_missing(*args) "#{publish_state.downcase}?" == args[0].to_s else # Used to query for any field on the relevant ContentType and return data from the content_item - field_items.select { |field_item| field_item.field.name.parameterize({ separator: '_' }) == args[0].to_s }.first.data.values[0] + field_items.select { |field_item| field_item.field.name.parameterize(separator: '_') == args[0].to_s }.first.data.values[0] end end end diff --git a/app/models/content_type.rb b/app/models/content_type.rb index 4730a129a..e0c19b8eb 100644 --- a/app/models/content_type.rb +++ b/app/models/content_type.rb @@ -25,7 +25,7 @@ def self.permissions end def content_items_index_name - content_type_name_sanitized = name.parameterize('_') + content_type_name_sanitized = name.parameterize(separator: '_') "#{Rails.env}_content_type_#{content_type_name_sanitized}_content_items" end From b38dd958577bc3ba689be6597a0c9095a9fe0612 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Tue, 9 May 2017 13:46:08 -0500 Subject: [PATCH 2/4] feat: update publish_filter queries for 5.4.0 --- app/models/concerns/searchable.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index e59bc8f09..1fd9acb2a 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -35,9 +35,9 @@ def range_search(field, type, q) def published_filter # Bring in documents based on Draft status, Published date met, or either: Expired date not yet met, or Expired date null [ - {bool: {should: [term_search(:draft, false)]}}, - {bool: {should: [range_search(:published_at, :lte, DateTime.now.to_s)]}}, - {bool: {should: [range_search(:expired_at, :gte, DateTime.now.to_s), {missing: { field: :expired_at }}]}} + {bool: {must: [term_search(:draft, false)]}}, + {bool: {must: [range_search(:published_at, :lte, DateTime.now.to_s)]}}, + {bool: {should: [range_search(:expired_at, :gte, DateTime.now.to_s), {bool: {must_not: {exists: { field: :expired_at }}}}]}} ] end end From ff77a2aaf8437efaec569c5981dc1554fc72a2f8 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Wed, 10 May 2017 11:04:58 -0500 Subject: [PATCH 3/4] bump: cortex-plugins-core to 0.12.4 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 260e9f0ae..8334b9de6 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.0.2' # Cortex-specific gem 'cortex-exceptions', '= 0.0.4' -gem 'cortex-plugins-core', '= 0.12.3' +gem 'cortex-plugins-core', '= 0.12.4' # API gem 'grape', '~> 0.17' From 6438fc227d384990e506d420923aeb902d834440 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Thu, 18 May 2017 11:18:21 -0500 Subject: [PATCH 4/4] feat: sort published post feed by `published_at` --- Gemfile.lock | 9 +++++---- app/models/concerns/searchable_post.rb | 10 +++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 728064bd5..ab7f737e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -136,7 +136,7 @@ GEM concurrent-ruby (1.0.5) connection_pool (2.2.1) cortex-exceptions (0.0.4) - cortex-plugins-core (0.12.3) + cortex-plugins-core (0.12.4) cells (~> 4.1) cells-haml (~> 0.0) cells-rails (~> 0.0) @@ -172,7 +172,7 @@ GEM dotenv-rails (2.2.1) dotenv (= 2.2.1) railties (>= 3.2, < 5.2) - down (2.4.3) + down (2.5.1) elasticsearch (5.0.4) elasticsearch-api (= 5.0.4) elasticsearch-transport (= 5.0.4) @@ -327,8 +327,9 @@ GEM json_spec (1.1.4) multi_json (~> 1.0) rspec (>= 2.0, < 4.0) - jsonb_accessor (1.0.0.beta.4) + jsonb_accessor (1.0.0.beta.6) activerecord (>= 5.0) + activesupport (>= 5.0) pg (>= 0.18.1) kaminari (0.17.0) actionpack (>= 3.0.0) @@ -618,7 +619,7 @@ DEPENDENCIES cells-rails (~> 0.0.7) codeclimate-test-reporter (~> 0.6) cortex-exceptions (= 0.0.4) - cortex-plugins-core (= 0.12.3) + cortex-plugins-core (= 0.12.4) database_cleaner (~> 1.5) deep_cloneable (~> 2.2.2) devise (~> 4.2.1) diff --git a/app/models/concerns/searchable_post.rb b/app/models/concerns/searchable_post.rb index e8142c31c..71b2166aa 100644 --- a/app/models/concerns/searchable_post.rb +++ b/app/models/concerns/searchable_post.rb @@ -93,11 +93,13 @@ def search_with_params(params, tenant, published = nil) if author bool[:bool][:filter] << term_search(:author, author) end + if published bool[:bool][:filter] << published_filter + search query: bool, sort: [{is_sticky: {order: 'desc'}, published_at: {order: 'desc'}}] + else + search query: bool end - - search query: bool end def show_all(tenant, published = nil) @@ -105,9 +107,11 @@ def show_all(tenant, published = nil) if published bool[:bool][:filter] << published_filter + search query: bool, sort: [{is_sticky: {order: 'desc'}, published_at: {order: 'desc'}}] + else + search query: bool, sort: [{is_sticky: {order: 'desc'}, created_at: {order: 'desc'}}] end - search query: bool, sort: [{is_sticky: {order: 'desc'}, created_at: {order: 'desc'}}] end end end