<commit_before>class Task::Volunteer < Mutations::Command
  required do
    model :user
    model :task
  end

  def execute
    assignment = Task::Role.send('task.volunteer').create(task: task, user: user)

    add_error :assignment, :failed unless assignment.persisted?

    assignment
  end
end<commit_msg>prevent the same person volunteering multiple times<commit_after>class Task::Volunteer < Mutations::Command
  required do
    model :user
    model :task
  end

  def validate
    add_error(:user, :already_volunteerd) if Task::Role.send('task.volunteer').where(task: task, user: user).exists?
  end

  def execute
    assignment = Task::Role.send('task.volunteer').create(task: task, user: user)

    add_error :assignment, :failed unless assignment.persisted?

    assignment
  end
end
{'fraction_non_alphanumeric': 0.1018867924528302, 'fraction_numerical': 0.0, 'mean_word_length': 4.2368421052631575, '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': '7224993', 'n_tokens_mistral': 245, 'n_tokens_neox': 240, 'n_words': 65}