docbrown/app/controllers/api/v0/videos_controller.rb
rhymes 5782ffd7e0 Use published scope for articles (#2374)
* Use published scope for articles

* Fix variable name

* The sequencing in the union query matters

* Fix spec

* Restore a published: true condition

* This test is actually misleading due to the union

* Revert this change, not sure why it's not a relation

* Fix useless diff
2019-04-11 13:18:26 -04:00

22 lines
625 B
Ruby

module Api
module V0
class VideosController < ApiController
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json
before_action :cors_preflight_check
after_action :cors_set_access_control_headers
def index
@page = params[:page]
@video_articles = Article.published.
where.not(video: [nil, ""], video_thumbnail_url: [nil, ""]).
where("score > ?", -4).
order("hotness_score DESC").
page(params[:page].to_i).per(24)
end
end
end
end