<commit_before>class DeviationSpider < ActiveRecord::Base
  	has_many    :deviation_spider_consolidations
  	has_many    :deviation_spider_deliverables
  	has_many	:deviation_spider_activity_values
  	has_many	:deviation_spider_deliverable_values
	belongs_to 	:milestone


	Spider_parameters = Struct.new(:deliverables, :activities)

	def init_spider_data

		spider_parameters = self.get_parameters

		# Create data
		spider_parameters.deliverables.each do |deliverable|
			add_deliverable(deliverable, spider_parameters.activities)
		end
	end

	def add_deliverable(deliverable, activities)
		new_spider_deliverable = DeviationSpiderDeliverable.new
		new_spider_deliverable.deviation_spider_id = self.id
		new_spider_deliverable.deviation_deliverable_id = deliverable.id
		if deliverable_not_done?(deliverable.id)
			new_spider_deliverable.not_done = true
		end		
		new_spider_deliverable.save

		activities.each do |activity|
			questions = DeviationQuestion.find(:all, :conditions => ["deviation_deliverable_id = ? and deviation_activity_id = ?", deliverable.id, activity.id])
			questions.each do |question|
				new_deviation_spider_values = DeviationSpiderValue.new
				new_deviation_spider_values.deviation_question_id = question.id
				new_deviation_spider_values.deviation_spider_deliverable_id = new_spider_deliverable.id
				if new_spider_deliverable.not_done
					new_deviation_spider_values.answer = false
				else
					new_deviation_spider_values.answer = nil
				end
				new_deviation_spider_values.answer_reference = question.answer_reference
				new_deviation_spider_values.save
			end
		end
	end

	def get_parameters
		activities 		= Array.new
		deliverables 	= Array.new<commit_msg>little update<commit_after>class DeviationSpider < ActiveRecord::Base
  	has_many    :deviation_spider_consolidations
  	has_many    :deviation_spider_deliverables
  	has_many	:deviation_spider_activity_values
  	has_many	:deviation_spider_deliverable_values
	belongs_to 	:milestone


	Spider_parameters = Struct.new(:deliverables, :activities)

	def init_spider_data

		spider_parameters = self.get_parameters

		# Create data
		spider_parameters.deliverables.each do |deliverable|
			add_deliverable(deliverable, spider_parameters.activities)
		end
	end

	def add_deliverable(deliverable, activities, init_answers=false)
		new_spider_deliverable = DeviationSpiderDeliverable.new
		new_spider_deliverable.deviation_spider_id = self.id
		new_spider_deliverable.deviation_deliverable_id = deliverable.id
		if deliverable_not_done?(deliverable.id)
			new_spider_deliverable.not_done = true
		end		
		new_spider_deliverable.save

		activities.each do |activity|
			questions = DeviationQuestion.find(:all, :conditions => ["deviation_deliverable_id = ? and deviation_activity_id = ?", deliverable.id, activity.id])
			questions.each do |question|
				new_deviation_spider_values = DeviationSpiderValue.new
				new_deviation_spider_values.deviation_question_id = question.id
				new_deviation_spider_values.deviation_spider_deliverable_id = new_spider_deliverable.id
				if new_spider_deliverable.not_done
					new_deviation_spider_values.answer = false
				else
					if init_answers
						# TODO : Init anwsers with previous spider deliverable only if we add the deliverable with the hand
					else
						new_deviation_spider_values.answer = nil
					end
				end
				new_deviation_spider_values.answer_reference = question.answer_reference
				new_deviation_spider_values.save
			end
		end
	end

	def get_parameters
		activities 		= Array.new
		deliverables 	= Array.new
{'fraction_non_alphanumeric': 0.0544179523141655, 'fraction_numerical': 0.0, 'mean_word_length': 5.289241622574956, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3371895', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1197, 'n_words': 189}