Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/controllers/api/v1/channels_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/v1/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -148,6 +148,7 @@ def fetch_communities(type:)
.exclude_array_ids
.exclude_incomplete_channels
.exclude_deleted_channels
.exclude_not_recommended
.ordered_pos_name
end

Expand Down
7 changes: 5 additions & 2 deletions app/controllers/api/v1/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -59,4 +62,4 @@ def check_authorization_header

end
end
end
end
2 changes: 2 additions & 0 deletions app/models/community.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
8 changes: 4 additions & 4 deletions app/serializers/api/v1/collection_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -94,7 +94,7 @@ def self.default_channels(object, params)
else
[]
end

Api::V1::ChannelSerializer.new(communities).serializable_hash
end

Expand Down