<commit_before>require 'fileutils'

namespace :polls do

desc "Create second citizen poll"
  task setup: :environment do
    # tricky to destroy, dependent on existent results, use only in dev env
    # destroy_all

    (1..10).each do |i|
      poll = Poll.new(poll_attributes(i))
      if poll.save
        print "."
      else
        puts poll.errors.first
      end
    end
  end

  def poll_attributes(i)
    { name: "Rehabilitar la plaza #{main_square_names[i]}",
      starts_at: Date.yesterday,
      ends_at: 1.week.from_now,
      geozone_restricted: false,
      questions_attributes: [
        { title: "¿Quieres rehabilitar la plaza #{i}?",
          valid_answers: "Sí, No",
          author: User.first,
          author_visible_name: author_name,
          poll: Poll.last
          },
          title: "¿Qué plaza te gusta más?",
          valid_answers: "Plaza X, Plaza Y",
          author: User.first,
          author_visible_name: author_name,
          poll: Poll.last
      ]
    }
  end

  def author_name<commit_msg>uses name for main _square in polls rake<commit_after>require 'fileutils'

namespace :polls do

desc "Create second citizen poll"
  task setup: :environment do
    # tricky to destroy, dependent on existent results, use only in dev env
    # destroy_all

    (1..10).each do |i|
      poll = Poll.new(poll_attributes(i))
      if poll.save
        print "."
      else
        puts poll.errors.first
      end
    end
  end

  def poll_attributes(i)
    { name: "Rehabilitar la plaza #{main_square_names[i]}",
      starts_at: Date.yesterday,
      ends_at: 1.week.from_now,
      geozone_restricted: false,
      questions_attributes: [
        { title: "¿Quieres rehabilitar la plaza #{main_square_names[i]}?",
          valid_answers: "Sí, No",
          author: User.first,
          author_visible_name: author_name,
          poll: Poll.last
          },
          title: "¿Qué plaza te gusta más?",
          valid_answers: "Plaza X, Plaza Y",
          author: User.first,
          author_visible_name: author_name,
          poll: Poll.last
      ]
    }
  end

  def author_name
{'fraction_non_alphanumeric': 0.0947467166979362, 'fraction_numerical': 0.00375234521575985, 'mean_word_length': 2.183582089552239, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3058202', 'n_tokens_mistral': 697, 'n_tokens_neox': 671, 'n_words': 186}