* Update email subjects split test * Create alternate editor * Add proof of concept to emails * Add utm for internal nav * Add ability to boost in DEV Digest * Adjust articles.scss * Adjust article_form.scss * Remove unnecessary files * Remove files from PR * Adjust boosted email settings * Conditionally include organization in additional box * Modify schema.rb
42 lines
1.3 KiB
Ruby
42 lines
1.3 KiB
Ruby
module Api
|
|
module V0
|
|
class ArticlesController < ApiController
|
|
before_action :set_cache_control_headers, only: [:index]
|
|
caches_action :show,
|
|
:cache_path => Proc.new { |c| c.params.permit! },
|
|
:expires_in => 5.minutes
|
|
respond_to :json
|
|
|
|
before_action :cors_preflight_check
|
|
after_action :cors_set_access_control_headers
|
|
|
|
def index
|
|
@articles = ArticleApiIndexService.new(params).get
|
|
set_surrogate_key_header "articles_api_#{params[:tag]}_#{params[:page]}_#{params[:userame]}_#{params[:signature]}_#{params[:state]}"
|
|
end
|
|
|
|
def show
|
|
@article = Article.includes(:user).find(params[:id]).decorate
|
|
not_found unless @article.published
|
|
end
|
|
|
|
def onboarding
|
|
tag_list = if params[:tag_list].present?
|
|
params[:tag_list].split(",")
|
|
else
|
|
["career", "discuss", "productivity"]
|
|
end
|
|
@articles = []
|
|
4.times do
|
|
@articles << ClassicArticle.new.get(tag_list)
|
|
end
|
|
Article.tagged_with(tag_list, any: true).
|
|
order("published_at DESC").
|
|
where("positive_reactions_count > ? OR comments_count > ?", 10, 3).limit(15).each do |article|
|
|
@articles << article
|
|
end
|
|
@articles = @articles.uniq.sample(6)
|
|
end
|
|
end
|
|
end
|
|
end
|