<commit_before># frozen_string_literal: true

class PlantingsController < DataController
  after_action :update_crop_medians, only: %i(create update destroy)
  after_action :update_planting_medians, only: :update

  def index
    @show_all = params[:all] == '1'

    where = {}
    where['active'] = true unless @show_all

    if params[:member_slug]
      @owner = Member.find_by(slug: params[:member_slug])
      where['owner_id'] = @owner.id
    end

    if params[:crop_slug]
      @crop = Crop.find_by(slug: params[:crop_slug])
      where['crop_id'] = @crop.id
    end

    @plantings = Planting.search(
      where:    where,
      page:     params[:page],
      limit:    30,
      boost_by: [:created_at],
      load:     false
    )

    @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv"

    respond_with(@plantings)
  end

  def show
    @photos = @planting.photos.includes(:owner).order(date_taken: :desc)
    @harvests = Harvest.search(where: { planting_id: @planting.id })
    @matching_seeds = matching_seeds
    @crop = @planting.crop
<commit_msg>protect against not finding a crop<commit_after># frozen_string_literal: true

class PlantingsController < DataController
  after_action :update_crop_medians, only: %i(create update destroy)
  after_action :update_planting_medians, only: :update

  def index
    @show_all = params[:all] == '1'

    where = {}
    where['active'] = true unless @show_all

    if params[:member_slug]
      @owner = Member.find_by(slug: params[:member_slug])
      where['owner_id'] = @owner.id
    end

    if params[:crop_slug]
      @crop = Crop.find_by(slug: params[:crop_slug])
      where['crop_id'] = @crop.id unless @crop.nil?
    end

    @plantings = Planting.search(
      where:    where,
      page:     params[:page],
      limit:    30,
      boost_by: [:created_at],
      load:     false
    )

    @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv"

    respond_with(@plantings)
  end

  def show
    @photos = @planting.photos.includes(:owner).order(date_taken: :desc)
    @harvests = Harvest.search(where: { planting_id: @planting.id })
    @matching_seeds = matching_seeds
    @crop = @planting.crop

{'fraction_non_alphanumeric': 0.13055181695827725, 'fraction_numerical': 0.0026917900403768506, 'mean_word_length': 3.3133462282398454, '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': '7135754', 'n_tokens_mistral': 796, 'n_tokens_neox': 780, 'n_words': 149}