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

  # TODO validate & handle error
  def execute
    cloned_task = Task.new(new_task_attributes)
    cloned_task
  end

  private

  # TODO: what about task roles?
  def new_task_attributes
    task.attributes.reject do |key, value|
      %w(id created_at updated_at completed_at).include?(key) || value.nil?
    end
  end

end<commit_msg>Clone task: also clone organizer. Location still isn’t cloned, takes some time to adapt code.<commit_after>class Task::Clone < Mutations::Command
  required do
    model :user
    model :task
  end

  # TODO validate & handle error
  def execute
    Task.new(new_task_attributes)
  end

  private

  def new_task_attributes
    attrs = task.attributes.reject do |key, value|
      %w(id created_at updated_at completed_at).include?(key) || value.nil?
    end
    attrs[:organizers] = task.organizers
    # FIXME primary task location must still be cloned
    attrs
  end

end
{'fraction_non_alphanumeric': 0.07654563297350343, 'fraction_numerical': 0.0, 'mean_word_length': 3.358974358974359, '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': '6930157', 'n_tokens_mistral': 316, 'n_tokens_neox': 312, 'n_words': 98}