<commit_before>class CheckAssignmentsController < ApplicationController
  expose(:project_checks_repository) { ProjectChecksRepository.new }
  expose(:check) do
    project_checks_repository.find(params[:project_check_id])
  end

  expose(:assignments_repository) { CheckAssignmentsRepository.new }
  expose(:assignment) { assignments_repository.latest_assignment(check) }
  expose(:users_repository) { UsersRepository.new }
  expose(:last_checker) do
    assignment.nil? ? nil : assignment.user
  end

  def assign_checker
    checker = PickCheckerService.new(
      repository: users_repository,
      latest_checker: last_checker,
    ).call

    AssignmentsService.new(
      checker: checker,
      completed: false,
      project_check_id: check.id,
      assignments: assignments_repository,
    ).call

    redirect_to reminder_path(check.reminder),
                notice: assigned_checker_notice(checker)
  end

  def complete_check
    check_assignment = AssignmentsService.new(
      assignment: assignment,
      checker: current_user,
      completed: true,
      project_check_id: check.id,
      assignments: assignments_repository,
    ).call

    update_project_check(check_assignment) unless check_assignment.nil?

    redirect_to reminder_path(check.reminder), notice: "All right"
  end

  private

  def update_project_check(check_assignment)
    update_params = {
      last_check_date: check_assignment.completion_date,
      last_check_user_id: check_assignment.user_id,
    }

    project_checks_repository.update(check, update_params)
  end

  def assigned_checker_notice(checker)
    "#{checker.name} was assigned to do next
    #{check.reminder.name} in #{check.project.name}"
  end
end
<commit_msg>no need to expose it here<commit_after>class CheckAssignmentsController < ApplicationController
  expose(:project_checks_repository) { ProjectChecksRepository.new }
  expose(:check) do
    project_checks_repository.find(params[:project_check_id])
  end
  expose(:assignments_repository) { CheckAssignmentsRepository.new }
  expose(:assignment) { assignments_repository.latest_assignment(check) }
  expose(:last_checker) do
    assignment.nil? ? nil : assignment.user
  end

  def assign_checker
    checker = PickCheckerService.new(
      repository: users_repository,
      latest_checker: last_checker,
    ).call

    AssignmentsService.new(
      checker: checker,
      completed: false,
      project_check_id: check.id,
      assignments: assignments_repository,
    ).call

    redirect_to reminder_path(check.reminder),
                notice: assigned_checker_notice(checker)
  end

  def complete_check
    check_assignment = AssignmentsService.new(
      assignment: assignment,
      checker: current_user,
      completed: true,
      project_check_id: check.id,
      assignments: assignments_repository,
    ).call

    update_project_check(check_assignment) unless check_assignment.nil?

    redirect_to reminder_path(check.reminder), notice: "All right"
  end

  private

  def update_project_check(check_assignment)
    update_params = {
      last_check_date: check_assignment.completion_date,
      last_check_user_id: check_assignment.user_id,
    }

    project_checks_repository.update(check, update_params)
  end

  def assigned_checker_notice(checker)
    "#{checker.name} was assigned to do next
    #{check.reminder.name} in #{check.project.name}"
  end
end

{'fraction_non_alphanumeric': 0.07793729856431292, 'fraction_numerical': 0.0, 'mean_word_length': 4.0652818991097925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5004102', 'n_tokens_mistral': 1023, 'n_tokens_neox': 1020, 'n_words': 189}