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