<commit_before>class Delivery < ActiveRecord::Base
  belongs_to :email
  belongs_to :address

  def delivered
    unless postfix_log_lines.empty?
      postfix_log_lines.any? {|l| l.delivered? }
    end
  end

  def delivered_status_known?
    !delivered.nil?
  end

  def postfix_log_lines
    email.postfix_log_lines.select{|l| l.to == address.text}
  end
end
<commit_msg>Small refactor to do query in db<commit_after>class Delivery < ActiveRecord::Base
  belongs_to :email
  belongs_to :address

  def delivered
    unless postfix_log_lines.empty?
      postfix_log_lines.any? {|l| l.delivered? }
    end
  end

  def delivered_status_known?
    !delivered.nil?
  end

  def postfix_log_lines
    email.postfix_log_lines.where(to: address.text)
  end
end

{'fraction_non_alphanumeric': 0.079155672823219, 'fraction_numerical': 0.0, 'mean_word_length': 3.685185185185185, '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': '3061964', 'n_tokens_mistral': 277, 'n_tokens_neox': 267, 'n_words': 59}