3980e9651e
Reviewed-on: #357 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
23 行
734 B
Ruby
23 行
734 B
Ruby
class TheatreProgrammesController < ApplicationController
|
|
def index
|
|
limit = params[:limit].to_i
|
|
limit = 100 if limit <= 0
|
|
|
|
position_gt = params[:position_gt].to_i
|
|
position_gt = 0 if position_gt < 0
|
|
|
|
programmes = TheatreProgramme
|
|
.where(theatre_id: params[:theatre_id])
|
|
.where('position > ?', position_gt)
|
|
.includes(:post)
|
|
.order(position: :desc).limit(100)
|
|
.limit(limit)
|
|
|
|
render json: programmes.map { |programme|
|
|
programme.as_json.merge(post: { id: programme.post.id,
|
|
title: programme.post.title,
|
|
url: programme.post.url })
|
|
}
|
|
end
|
|
end
|