module Recordings
  class ClubStats
    def initialize(club)
      @club = club
    end

    def call
      scope = Recording.for_club(@club).not_deleted
      ready = scope.ready
      {
        available_count: ready.count,
        expiring_soon_count: ready.expiring_within(7).count,
        total_bytes: ready.sum(:byte_size).to_i,
        total_views: ready.sum(:view_count).to_i,
        processing_count: scope.where(status: "processing").count,
        failed_count: scope.where(status: "failed").count
      }
    end
  end
end
