29 lines
620 B
Ruby
29 lines
620 B
Ruby
class VideoAnalyses::AcquiredMediaReleasesController < ApplicationController
|
|
before_action :set_video
|
|
|
|
def index
|
|
@acquired_media_files = filtered_files
|
|
end
|
|
|
|
private
|
|
|
|
def set_video
|
|
@video = Video.find(params[:video_id])
|
|
end
|
|
|
|
def query_param
|
|
params[:query]
|
|
end
|
|
|
|
def filtered_files
|
|
releasables = policy_scope(@video.acquired_media_releases)
|
|
results = ActiveStorage::Attachment.where(record: releasables, name: "files")
|
|
|
|
if query_param.present?
|
|
results = results.joins(:blob).where("active_storage_blobs.filename ILIKE ?", "%#{query_param}%")
|
|
end
|
|
|
|
results
|
|
end
|
|
end
|