<commit_before>class CouponFirstPurchaseValue < CouponValue
  def eligible?(order, at = Time.zone.now )
    (starts_at <= at && expires_at >= at) && order.user.try(:number_of_finished_orders_at, at)
  end
end

class CouponFirstPurchasePercent < CouponPercent
  def eligible?(order, at = Time.zone.now)
    (starts_at <= at && expires_at >= at) && order.user.try(:number_of_finished_orders_at, at)
  end
end<commit_msg>if the order doesn't have a user then the first purchase discount is false<commit_after>class CouponFirstPurchaseValue < CouponValue
  def eligible?(order, at = Time.zone.now )
    (starts_at <= at && expires_at >= at) && (order.user.try(:number_of_finished_orders_at, at) == 0) rescue false
  end
end

class CouponFirstPurchasePercent < CouponPercent
  def eligible?(order, at = Time.zone.now)
    (starts_at <= at && expires_at >= at) && (order.user.try(:number_of_finished_orders_at, at) == 0) rescue false
  end
end
{'fraction_non_alphanumeric': 0.11846318036286019, 'fraction_numerical': 0.0021344717182497333, 'mean_word_length': 5.012820512820513, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '4104943', 'n_tokens_mistral': 318, 'n_tokens_neox': 322, 'n_words': 78}