-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add role targeting to billboards #21270
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [rubocop] <Metrics/CyclomaticComplexity> reported by reviewdog 🐶
Cyclomatic complexity for call is too high. [14/13]
forem/app/queries/billboards/filtered_ads_query.rb
Lines 32 to 81 in d9aa5e9
def call | |
@filtered_billboards = approved_and_published_ads | |
@filtered_billboards = placement_area_ads | |
@filtered_billboards = browser_context_ads if @user_agent.present? | |
@filtered_billboards = page_ads if @page_id.present? | |
@filtered_billboards = cookies_allowed_ads unless @cookies_allowed | |
if @article_id.present? | |
if @article_tags.any? | |
@filtered_billboards = tagged_ads(@article_tags).or(untagged_ads) | |
end | |
if @article_tags.blank? | |
@filtered_billboards = untagged_ads | |
end | |
@filtered_billboards = unexcluded_article_ads | |
end | |
if @user_tags.present? && @user_tags.any? | |
@filtered_billboards = tagged_ads(@user_tags).or(untagged_ads) | |
end | |
# We apply the condition feed_targeted_tag_placement? because we only want to filter by | |
# untagged ads on the home feed area placements. We do not want to have any side effects happen | |
# on the article page or anywhere else. | |
if @user_tags.blank? && feed_targeted_tag_placement?(@area) | |
@filtered_billboards = untagged_ads | |
end | |
@filtered_billboards = user_targeting_ads | |
@filtered_billboards = role_filtered_ads if @user_signed_in | |
@filtered_billboards = if @user_signed_in | |
authenticated_ads(%w[all logged_in]) | |
else | |
authenticated_ads(%w[all logged_out]) | |
end | |
if FeatureFlag.enabled?(Geolocation::FEATURE_FLAG) | |
@filtered_billboards = location_targeted_ads | |
end | |
# type_of filter needs to be applied as near to the end as possible | |
# as it checks if any type-matching ads exist (this will apply all/any | |
# filters applied up to this point, thus near the end is best) | |
@filtered_billboards = type_of_ads | |
@filtered_billboards = @filtered_billboards.order(success_rate: :desc) | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [rubocop] <Metrics/PerceivedComplexity> reported by reviewdog 🐶
Perceived complexity for call is too high. [15/14]
forem/app/queries/billboards/filtered_ads_query.rb
Lines 32 to 81 in d9aa5e9
def call | |
@filtered_billboards = approved_and_published_ads | |
@filtered_billboards = placement_area_ads | |
@filtered_billboards = browser_context_ads if @user_agent.present? | |
@filtered_billboards = page_ads if @page_id.present? | |
@filtered_billboards = cookies_allowed_ads unless @cookies_allowed | |
if @article_id.present? | |
if @article_tags.any? | |
@filtered_billboards = tagged_ads(@article_tags).or(untagged_ads) | |
end | |
if @article_tags.blank? | |
@filtered_billboards = untagged_ads | |
end | |
@filtered_billboards = unexcluded_article_ads | |
end | |
if @user_tags.present? && @user_tags.any? | |
@filtered_billboards = tagged_ads(@user_tags).or(untagged_ads) | |
end | |
# We apply the condition feed_targeted_tag_placement? because we only want to filter by | |
# untagged ads on the home feed area placements. We do not want to have any side effects happen | |
# on the article page or anywhere else. | |
if @user_tags.blank? && feed_targeted_tag_placement?(@area) | |
@filtered_billboards = untagged_ads | |
end | |
@filtered_billboards = user_targeting_ads | |
@filtered_billboards = role_filtered_ads if @user_signed_in | |
@filtered_billboards = if @user_signed_in | |
authenticated_ads(%w[all logged_in]) | |
else | |
authenticated_ads(%w[all logged_out]) | |
end | |
if FeatureFlag.enabled?(Geolocation::FEATURE_FLAG) | |
@filtered_billboards = location_targeted_ads | |
end | |
# type_of filter needs to be applied as near to the end as possible | |
# as it checks if any type-matching ads exist (this will apply all/any | |
# filters applied up to this point, thus near the end is best) | |
@filtered_billboards = type_of_ads | |
@filtered_billboards = @filtered_billboards.order(success_rate: :desc) | |
end |
Uffizzi Preview |
What type of PR is this? (check all applicable)
Description
Adds the ability to filter billboards by user's roles.