class FileInfo < ApplicationRecord
  belongs_to :releasable, polymorphic: true

  scope :audio, -> { where("content_type ILIKE ?", "%audio%") }
  scope :video, -> { where("content_type ILIKE ?", "%video%") }
  scope :photo, -> { where("content_type ILIKE ?", "%image%") }
  scope :other, -> { where("NOT content_type ILIKE ?", "%(image|video|audio)%") }

  def self.search_filename(query)
    where("filename ILIKE ?", "%#{query}%")
  end
end
