* Trying some models for audience segmentation * AudienceSegment basics * Attach AudienceSegment to DisplayAd * Possibly use a DUS to populate AudienceSegments * Add to display ad form UI * Add to display ad API * Refresh strategy for audience segments * Add user_id to async ads query * Maybe :testing -> :manual, for no-refresh segment * Test & tweak segment refresh * Testing audience_segment#refresh logic * Coverage: testing human_readable * Scope segment refresh to recently active users * Tweak logic for when to refresh * Tweak experience levels to match SettingsHelper * Test for front-end logic * Fix test, hope this helps coverage? * Better test names * One worker for all, many workers for each, perform_bulk * Fix audience segment UI, needs to use id, not enum * cron/schedule should RefreshAll * Singular id in RefreshWorker
31 lines
1 KiB
Ruby
31 lines
1 KiB
Ruby
class DisplayAdsController < ApplicationController
|
|
before_action :set_cache_control_headers, only: %i[show], unless: -> { current_user }
|
|
CACHE_EXPIRY_FOR_DISPLAY_ADS = 15.minutes.to_i.freeze
|
|
|
|
def show
|
|
skip_authorization
|
|
set_cache_control_headers(CACHE_EXPIRY_FOR_DISPLAY_ADS) unless session_current_user_id
|
|
|
|
if params[:placement_area]
|
|
if params[:username].present? && params[:slug].present?
|
|
@article = Article.find_by(slug: params[:slug])
|
|
end
|
|
|
|
@display_ad = DisplayAd.for_display(
|
|
area: params[:placement_area],
|
|
user_signed_in: user_signed_in?,
|
|
user_id: current_user&.id,
|
|
organization_id: @article&.organization_id,
|
|
permit_adjacent_sponsors: ArticleDecorator.new(@article).permit_adjacent_sponsors?,
|
|
article_tags: @article&.decorate&.cached_tag_list_array || [],
|
|
article_id: @article&.id,
|
|
)
|
|
|
|
if @display_ad && !session_current_user_id
|
|
set_surrogate_key_header @display_ad.record_key
|
|
end
|
|
end
|
|
|
|
render layout: false
|
|
end
|
|
end
|