Use predicted finish times to put current plantings on the timeline

This commit is contained in:
Brenda Wallace
2018-01-12 08:07:38 +13:00
parent c442bdbd45
commit cc1d3b4f43
2 changed files with 9 additions and 4 deletions

View File

@@ -61,10 +61,15 @@ class GardensController < ApplicationController
def timeline
@data = []
@garden = Garden.find(params[:garden_id])
@garden.plantings.where.not(finished_at: nil)
.where.not(planted_at: nil)
@garden.plantings.where.not(planted_at: nil)
.order(finished_at: :desc).each do |p|
@data << [p.crop.name, p.planted_at, p.finished_at]
finish = if p.finished_at.present?
p.finished_at
else
p.finish_predicted_at
end
@data << [p.crop.name, p.planted_at, finish] if finish.present?
end
render json: @data
end

View File

@@ -40,7 +40,7 @@
.row
= timeline garden_timeline_path(@garden), adapter: "google"
%h3 What's planted here?
%h3 Current plantings in garden
.row
- if @current_plantings.size.positive?
- @current_plantings.each do |planting|