<commit_before>module PhotosHelper
  def crop_image_path(crop)
    if crop.default_photo.present?
      crop.default_photo.thumbnail_url
    else
      placeholder_image
    end
  end

  def garden_image_path(garden)
    if garden.default_photo.present?
      garden.default_photo.thumbnail_url
    else
      placeholder_image
    end
  end

  def planting_image_path(planting)
    if planting.photos.present?
      planting.photos.first.thumbnail_url
    else
      placeholder_image
    end
  end

  def harvest_image_path(harvest)
    if harvest.photos.present?
      harvest.photos.first.thumbnail_url
    elsif harvest.planting.present? && harvest.planting.photos.present?
      harvest.planting.photos.first.thumbnail_url
    else
      placeholder_image
    end
  end

  def seed_image_path(seed)
    if seed.default_photo.present?
      seed.default_photo.thumbnail_url
    elsif seed.crop.default_photo.present?
      seed.crop.default_photo.thumbnail_url
    else
      placeholder_image
    end
  end

  private

  def placeholder_image
    'placeholder_150.png'
  end
end
<commit_msg>Pick the first photo<commit_after>module PhotosHelper
  def crop_image_path(crop)
    if crop.default_photo.present?
      crop.default_photo.thumbnail_url
    else
      placeholder_image
    end
  end

  def garden_image_path(garden)
    if garden.default_photo.present?
      garden.default_photo.thumbnail_url
    else
      placeholder_image
    end
  end

  def planting_image_path(planting)
    if planting.photos.present?
      planting.photos.order(date_taken: :desc).first.thumbnail_url
    else
      placeholder_image
    end
  end

  def harvest_image_path(harvest)
    if harvest.photos.present?
      harvest.photos.order(date_taken: :desc).first.thumbnail_url
    elsif harvest.planting.present?
        planting_image_path(harvest.planting)
    else
      placeholder_image
    end
  end

  def seed_image_path(seed)
    if seed.default_photo.present?
      seed.default_photo.thumbnail_url
    elsif seed.crop.default_photo.present?
      seed.crop.default_photo.thumbnail_url
    else
      placeholder_image
    end
  end

  private

  def placeholder_image
    'placeholder_150.png'
  end
end

{'fraction_non_alphanumeric': 0.05834464043419267, 'fraction_numerical': 0.0027137042062415195, 'mean_word_length': 3.0072463768115942, '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': '2946467', 'n_tokens_mistral': 731, 'n_tokens_neox': 702, 'n_words': 124}