diff --git a/app/controllers/api/v1/channels_controller.rb b/app/controllers/api/v1/channels_controller.rb index bcfd2727..01513553 100644 --- a/app/controllers/api/v1/channels_controller.rb +++ b/app/controllers/api/v1/channels_controller.rb @@ -26,7 +26,7 @@ def channel_detail account = local_account? ? current_account : current_remote_account render json: Api::V1::ChannelSerializer.new( @channel, - { + { params: { current_account: account } } ).serializable_hash.to_json @@ -63,12 +63,12 @@ def my_channel end def channel_feeds - channel_feeds = Community.filter_channel_feeds.exclude_incomplete_channels.exclude_deleted_channels.with_all_includes + channel_feeds = Community.filter_channel_feeds.exclude_incomplete_channels.exclude_deleted_channels.exclude_not_recommended.with_all_includes render json: Api::V1::ChannelSerializer.new(channel_feeds , { params: { current_account: current_account } }).serializable_hash.to_json end def newsmast_channels - newsmast_channels = Community.filter_newsmast_channels.exclude_incomplete_channels.with_all_includes + newsmast_channels = Community.filter_newsmast_channels.exclude_incomplete_channels.exclude_deleted_channels.exclude_not_recommended.with_all_includes if newsmast_channels.present? render json: Api::V1::ChannelSerializer.new(newsmast_channels , { params: { current_account: current_remote_account } }).serializable_hash.to_json else diff --git a/app/controllers/api/v1/collections_controller.rb b/app/controllers/api/v1/collections_controller.rb index 7937dca9..07af4b8f 100644 --- a/app/controllers/api/v1/collections_controller.rb +++ b/app/controllers/api/v1/collections_controller.rb @@ -27,7 +27,7 @@ class CollectionsController < ApiController 'Sport', 'Lifestyle' ].freeze - + def index @all_collections = fetch_all_channels_by_type(type: COLLECTION_TYPES[:channel]) render_collections(@all_collections, type: COLLECTION_TYPES[:channel]) @@ -148,6 +148,7 @@ def fetch_communities(type:) .exclude_array_ids .exclude_incomplete_channels .exclude_deleted_channels + .exclude_not_recommended .ordered_pos_name end diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index 6a5bfebf..5233ed08 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -6,7 +6,7 @@ class SearchController < ApiController def search query = build_query(params[:q]) - + render json: { communities: serialize_communities(query), channel_feeds: serialize_channel_feeds(query), @@ -26,6 +26,7 @@ def serialize_communities(query) .exclude_array_ids .exclude_incomplete_channels .exclude_deleted_channels + .exclude_not_recommended .where("lower(name) LIKE :q OR lower(slug) LIKE :q", q: query) Api::V1::ChannelSerializer.new(communities).serializable_hash @@ -37,6 +38,7 @@ def serialize_channel_feeds(query) .exclude_array_ids .exclude_incomplete_channels .exclude_deleted_channels + .exclude_not_recommended .where("lower(name) LIKE :q OR lower(slug) LIKE :q", q: query) Api::V1::ChannelSerializer.new(channel_feeds, { params: { current_account: current_account } }).serializable_hash @@ -48,6 +50,7 @@ def serialize_newsmast_communities(query) .exclude_array_ids .exclude_incomplete_channels .exclude_deleted_channels + .exclude_not_recommended .where("lower(name) LIKE :q OR lower(slug) LIKE :q", q: query) Api::V1::ChannelSerializer.new(newsmast_communities).serializable_hash @@ -59,4 +62,4 @@ def check_authorization_header end end -end \ No newline at end of file +end diff --git a/app/models/community.rb b/app/models/community.rb index 3f70d7e5..bbc7faf4 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -222,6 +222,8 @@ def formatted_error_messages scope :exclude_incomplete_channels, -> { where.not(patchwork_communities: { visibility: nil }).exclude_deleted_channels } + scope :exclude_not_recommended, -> { where.not(patchwork_communities: { is_recommended: false }) } + scope :exclude_deleted_channels, -> { where(patchwork_communities: { deleted_at: nil }) } enum visibility: { public_access: 0, guest_access: 1, private_local: 2 } diff --git a/app/serializers/api/v1/collection_serializer.rb b/app/serializers/api/v1/collection_serializer.rb index 251e7475..0267a915 100644 --- a/app/serializers/api/v1/collection_serializer.rb +++ b/app/serializers/api/v1/collection_serializer.rb @@ -60,11 +60,11 @@ def self.newsmast_community_count(object) def self.default_community_count(object, params) if object.slug == "all-collection" && params[:type] == 'channel' - Community.filter_channels.exclude_array_ids.exclude_incomplete_channels.exclude_deleted_channels.size + Community.filter_channels.exclude_array_ids.exclude_incomplete_channels.exclude_deleted_channels.exclude_not_recommended.size elsif object.slug == "all-collection" && params[:type] == 'channel_feed' - Community.filter_channel_feeds.exclude_array_ids.exclude_incomplete_channels.exclude_deleted_channels.size + Community.filter_channel_feeds.exclude_array_ids.exclude_incomplete_channels.exclude_deleted_channels.exclude_not_recommended.size else - object.patchwork_communities.exclude_array_ids.filter_channels.exclude_incomplete_channels.exclude_deleted_channels.size + object.patchwork_communities.exclude_array_ids.filter_channels.exclude_incomplete_channels.exclude_deleted_channels.exclude_not_recommended.size end end @@ -94,7 +94,7 @@ def self.default_channels(object, params) else [] end - + Api::V1::ChannelSerializer.new(communities).serializable_hash end