class LimitForbidControl::CompetitionApiScoreQy < LimitForbidControl::Base
  attr_reader :team_id

  def initialize(team_id)
    super()
    @team_id = team_id
  end

  def allow_times
    EduSetting.find_by(name: 'daily_api_score_times')&.value.presence || 1
  end

  def forbid_expires
    num = EduSetting.get('daily_api_score_forbid_time').presence.to_i
    num.zero? ? 1.hours : num.to_i.hours
  end

  def cumulative_expires
    3.days
  end

  def cache_key
    @_cache_key ||= "limit_forbid_control:#{day3}:competition_api_score:#{team_id}"
  end

  def day3
    Time.current.strftime('%Y%m')
  end
end