<commit_before>-#:ruby
  
  # for cartodb map #1 (Simple with category for )
  # 1 simple layer with activity as category
  
  campaign = Campaign.currents.last
  
  dataset_one = []
  
      ProductionSupport.includes({production: [:activity, :campaign, :variant]}, :storage).find_each do |support|
        
        item = {
          name:    support.name,
          shape:   (support.shape ? Charta::Geometry.new(support.shape).transform(:WGS84) : nil),
          campaign:   support.production.campaign.name,
          activity:   support.production.activity.name,
          production: support.production.name,
          variant:    support.production.variant.name,
          tool_cost:  support.tool_cost.to_s.to_f.round(2),
          input_cost: support.input_cost.to_s.to_f.round(2),
          time_cost:  support.time_cost.to_s.to_f.round(2)
        }
        
        dataset_one << item
      end
      
    # for cartodb map #2
    # 3 choropleth layer with nitrogen_balance, phosphorus_balance, potassium_balance as indicator
    
    dataset_two = []
    
      ProductionSupport.includes({production: [:activity, :campaign, :variant]}, :storage).find_each do |support|
        
        item = {
          name:    support.name,
          shape:   (support.shape ? Charta::Geometry.new(support.shape).transform(:WGS84) : nil),
          campaign:   support.production.campaign.name,
          activity:   support.production.activity.name,
          nitrogen_balance: support.nitrogen_balance.to_s.to_f.round(2),
          phosphorus_balance: support.phosphorus_balance.to_s.to_f.round(2),
          potassium_balance: support.potassium_balance.to_s.to_f.round(2),
          provisional_nitrogen_input: support.provisional_nitrogen_input.to_s.to_f.round(2)
        }
        
        dataset_two << item
        
      end

  

      choro = []
  
      dataset_one.each do |item|
        
        if item[:shape]
        
          choro << {style: 'choropleth', choropleth_value: 'area', choropleth_level_number: 7, choropleth_start_color: '#77a1e5', choropleth_end_color: '#910000', category: item[:activity], center: item[:shape].centroid, choropleth_type: 'linear', name: item[:name], area: item[:shape].area, coord: item[:shape].to_geojson, stroke: true , color: 'black', weight: 1, fillColor: 'white', opacity: 1, fill: true, fillOpacity: 0.8}
        
        end
      
      end


:ruby
  data = Plant.all.collect do |p|
    next unless p.shape
    
    popup_content = []
    
    # for all plant
    popup_content << {label: Plant.human_attribute_name(:net_surface_area), value: p.net_surface_area.in_hectare.round(2).l}
    popup_content << {label: Nomen::Varieties.find(p.nature.variety).human_name, value: Nomen::Varieties.find(p.variety).human_name}
    
    # for vine plant
    #if p.woodstock_variety
     # popup_content << {label: Nomen::Indicators.find(:woodstock_variety).human_name, value: Nomen::Varieties.find(p.woodstock_variety).human_name}
    #end
    
    # for indicators in list
    indicators = [:tiller_count, :plants_count, :rows_interval, :plants_interval, :rows_orientation]
    for indicator in indicators
      if !p.send(indicator).blank? and (p.send(indicator).to_d > 0.0)
        popup_content << {label: Nomen::Indicators.find(indicator.to_sym).human_name, value: p.send(indicator).l }
      end
    end
    
    if container = p.container
      popup_content << {label: :cultivable_zone.tl, value: link_to(container.name, backend_product_path(container)) }
    end

    if interventions = Intervention.with_cast(:target, p).reorder(:started_at)
      popup_content << {label: :interventions_count.tl, value: interventions.count }
    end

    if interventions.count > 0 and last_intervention = interventions.last
      popup_content << {label: :last_intervention.tl, value: link_to( "N°" + last_intervention.number, backend_intervention_path(last_intervention)) }
    end
    
    popup_content << render('popup', plant: p)
    
    
    {name: p.name, shape: p.shape, age: (Time.now - p.born_at) / (3600 * 24 * 30), interventions_count: interventions.count, popup: {header: true, content: popup_content} }
  end
      
= kujaku

- main_toolbar do |t|
  - t.new

= beehive do |b|
  - b.cell :plants do
    = visualization :plants do |v|
      - v.background :base, "OpenStreetMap.HOT"
      - v.background :forest_base, "Thunderforest"
      -# v.background :water_base, "Thunderforest.Transport"
      - v.background :landscape_base, "Thunderforest.Landscape"
      -# v.background :outdoors_base, "Thunderforest.Outdoors"
      -# v.background :map_quest_open_aerial, "MapQuestOpen.Aerial"
      - v.choropleth :age, data
      - v.choropleth :interventions_count, data
      - v.control :zoom
      - v.control :scale
      - v.control :fullscreen
      - v.control :layer_selector
          
  - b.cell :list do
    = list
<commit_msg>adapt plant map view<commit_after>-#:ruby
  
  # for cartodb map #1 (Simple with category for )
  # 1 simple layer with activity as category
  
  campaign = Campaign.currents.last
  
  dataset_one = []
  
      ProductionSupport.includes({production: [:activity, :campaign, :variant]}, :storage).find_each do |support|
        
        item = {
          name:    support.name,
          shape:   (support.shape ? Charta::Geometry.new(support.shape).transform(:WGS84) : nil),
          campaign:   support.production.campaign.name,
          activity:   support.production.activity.name,
          production: support.production.name,
          variant:    support.production.variant.name,
          tool_cost:  support.tool_cost.to_s.to_f.round(2),
          input_cost: support.input_cost.to_s.to_f.round(2),
          time_cost:  support.time_cost.to_s.to_f.round(2)
        }
        
        dataset_one << item
      end
      
    # for cartodb map #2
    # 3 choropleth layer with nitrogen_balance, phosphorus_balance, potassium_balance as indicator
    
    dataset_two = []
    
      ProductionSupport.includes({production: [:activity, :campaign, :variant]}, :storage).find_each do |support|
        
        item = {
          name:    support.name,
          shape:   (support.shape ? Charta::Geometry.new(support.shape).transform(:WGS84) : nil),
          campaign:   support.production.campaign.name,
          activity:   support.production.activity.name,
          nitrogen_balance: support.nitrogen_balance.to_s.to_f.round(2),
          phosphorus_balance: support.phosphorus_balance.to_s.to_f.round(2),
          potassium_balance: support.potassium_balance.to_s.to_f.round(2),
          provisional_nitrogen_input: support.provisional_nitrogen_input.to_s.to_f.round(2)
        }
        
        dataset_two << item
        
      end

  

      choro = []
  
      dataset_one.each do |item|
        
        if item[:shape]
        
          choro << {style: 'choropleth', choropleth_value: 'area', choropleth_level_number: 7, choropleth_start_color: '#77a1e5', choropleth_end_color: '#910000', category: item[:activity], center: item[:shape].centroid, choropleth_type: 'linear', name: item[:name], area: item[:shape].area, coord: item[:shape].to_geojson, stroke: true , color: 'black', weight: 1, fillColor: 'white', opacity: 1, fill: true, fillOpacity: 0.8}
        
        end
      
      end


:ruby
  data = Plant.all.collect do |p|
    next unless p.shape
    
    popup_content = []
    
    # for all plant
    popup_content << {label: Plant.human_attribute_name(:net_surface_area), value: p.net_surface_area.in_hectare.round(2).l}
    popup_content << {label: Nomen::Varieties.find(p.nature.variety).human_name, value: Nomen::Varieties.find(p.variety).human_name}
    
    # for vine plant
    #if p.woodstock_variety
     # popup_content << {label: Nomen::Indicators.find(:woodstock_variety).human_name, value: Nomen::Varieties.find(p.woodstock_variety).human_name}
    #end
    
    # for indicators in list
    indicators = [:tiller_count, :plants_count, :rows_interval, :plants_interval, :rows_orientation]
    for indicator in indicators
      if !p.send(indicator).blank? and (p.send(indicator).to_d > 0.0)
        popup_content << {label: Nomen::Indicators.find(indicator.to_sym).human_name, value: p.send(indicator).l }
      end
    end
    
    if container = p.container
      popup_content << {label: :cultivable_zone.tl, value: link_to(container.name, backend_product_path(container)) }
    end

    if interventions = Intervention.with_cast(:target, p).reorder(:started_at)
      popup_content << {label: :interventions_count.tl, value: interventions.count }
    end

    if interventions.count > 0 and last_intervention = interventions.last
      popup_content << {label: :last_intervention.tl, value: link_to( "N°" + last_intervention.number, backend_intervention_path(last_intervention)) }
    end
    
    if issues = Issue.where(target_id: p.id, target_type: p.class.name ).reorder(:observed_at)
      popup_content << {label: :issues_count.tl, value: issues.count }
    end
    
    if issues.count > 0 and last_issue = issues.last
      popup_content << {label: :last_issue.tl, value: link_to( last_issue.name, backend_issue_path(last_issue)) }
    end

    popup_content << render('popup', plant: p)
    
    
    {name: p.name, shape: p.shape, age: (Time.now - p.born_at) / (3600 * 24 * 30), interventions_count: interventions.count, issues_count: issues.count, popup: {header: true, content: popup_content} }
  end
      
= kujaku

- main_toolbar do |t|
  - t.new

= beehive do |b|
  - b.cell :plants do
    = visualization :plants do |v|
      - v.background :base, "OpenStreetMap.HOT"
      - v.background :forest_base, "Thunderforest"
      -# v.background :water_base, "Thunderforest.Transport"
      - v.background :landscape_base, "Thunderforest.Landscape"
      -# v.background :outdoors_base, "Thunderforest.Outdoors"
      -# v.background :map_quest_open_aerial, "MapQuestOpen.Aerial"
      - v.choropleth :age, data
      - v.choropleth :issues_count, data
      - v.choropleth :interventions_count, data
      - v.control :zoom
      - v.control :scale
      - v.control :fullscreen
      - v.control :layer_selector
          
  - b.cell :list do
    = list

{'fraction_non_alphanumeric': 0.11814180929095354, 'fraction_numerical': 0.008312958435207823, 'mean_word_length': 2.918007662835249, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 8, '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': '1774540', 'n_tokens_mistral': 3445, 'n_tokens_neox': 3256, 'n_words': 645}