<commit_before>class ResponseSet < ActiveRecord::Base
  include Surveyor::Models::ResponseSetMethods

  before_save :generate_certificate

  attr_accessible :dataset_id

  belongs_to :dataset
  belongs_to :survey
  has_one :certificate

  DEFAULT_TITLE = 'Untitled'

  scope :by_newest, order("response_sets.created_at DESC")
  scope :completed, where("response_sets.completed_at <> ''")

  def title
    title_determined_from_responses || ResponseSet::DEFAULT_TITLE
  end

  def title_determined_from_responses
    @title_determined_from_responses ||= responses.joins(:question).where(questions: {reference_identifier: 'dataTitle'}).first.try(:string_value)
  end

  def incomplete?
    !complete?
  end

  def triggered_mandatory_questions
    @triggered_mandatory_questions ||= self.survey.mandatory_questions.select { |q| q.triggered?(self) }
  end

  def triggered_requirements
    @triggered_requirements ||= survey.requirements.select { |r| r.triggered?(self) }
  end
<commit_msg>Bug with SQLite and Postgres not handling time fields the same<commit_after>class ResponseSet < ActiveRecord::Base
  include Surveyor::Models::ResponseSetMethods

  before_save :generate_certificate

  attr_accessible :dataset_id

  belongs_to :dataset
  belongs_to :survey
  has_one :certificate

  DEFAULT_TITLE = 'Untitled'

  scope :by_newest, order("response_sets.created_at DESC")
  scope :completed, where("response_sets.completed_at IS NOT NULL")

  def title
    title_determined_from_responses || ResponseSet::DEFAULT_TITLE
  end

  def title_determined_from_responses
    @title_determined_from_responses ||= responses.joins(:question).where(questions: {reference_identifier: 'dataTitle'}).first.try(:string_value)
  end

  def incomplete?
    !complete?
  end

  def triggered_mandatory_questions
    @triggered_mandatory_questions ||= self.survey.mandatory_questions.select { |q| q.triggered?(self) }
  end

  def triggered_requirements
    @triggered_requirements ||= survey.requirements.select { |r| r.triggered?(self) }
  end

{'fraction_non_alphanumeric': 0.09068506653523903, 'fraction_numerical': 0.0, 'mean_word_length': 5.633986928104576, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, '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': '6581481', 'n_tokens_mistral': 668, 'n_tokens_neox': 621, 'n_words': 121}