# frozen_string_literal: true

class AssignmentsController < ApiBaseController
  PERMITTED_INCLUDES = %w[turnins enrollment enrollment.user].freeze
  DEFAULT_INCLUDES = %w[turnins].freeze

  def index
    conditions = {}

    conditions[:contract_id] = params[:contractIds].split(',') if params[:contractIds]

    result = Assignment
      .where(conditions)
      .limit(@limit)

    count = Assignment.where(conditions).count

    render json: AssignmentSerializer.new(result, serializer_options({ meta: { count: count } }))
  end
end
