|
|
@ -80,21 +80,31 @@ class EntriesController < ApplicationController |
|
|
# Voraussichtliches Ende je Kombination basierend auf weekly_target_matrix |
|
|
# Voraussichtliches Ende je Kombination basierend auf weekly_target_matrix |
|
|
# |
|
|
# |
|
|
@estimated_end_by_typ_art = {} |
|
|
@estimated_end_by_typ_art = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@remaining_minutes_matrix.each do |typ, arts| |
|
|
@remaining_minutes_matrix.each do |typ, arts| |
|
|
@estimated_end_by_typ_art[typ] ||= {} |
|
|
@estimated_end_by_typ_art[typ] ||= {} |
|
|
|
|
|
|
|
|
arts.each do |art, remaining_minutes| |
|
|
arts.each do |art, remaining_minutes| |
|
|
hours_remaining = remaining_minutes / 60.0 |
|
|
hours_remaining = remaining_minutes / 60.0 |
|
|
weekly_hours = current_user.weekly_target_matrix.dig(typ, art).to_f |
|
|
weekly_hours = current_user.weekly_target_matrix.dig(typ, art).to_f |
|
|
if weekly_hours > 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
last_entry_date = current_user.entries |
|
|
|
|
|
.where(praktikums_typ: typ, entry_art: art) |
|
|
|
|
|
.maximum(:date) |
|
|
|
|
|
|
|
|
|
|
|
start_date = [last_entry_date, Date.today].compact.max |
|
|
|
|
|
|
|
|
|
|
|
if weekly_hours > 0 && hours_remaining > 0 |
|
|
weeks_remaining = (hours_remaining / weekly_hours).ceil |
|
|
weeks_remaining = (hours_remaining / weekly_hours).ceil |
|
|
@estimated_end_by_typ_art[typ][art] = Date.today + weeks_remaining.weeks |
|
|
|
|
|
|
|
|
@estimated_end_by_typ_art[typ][art] = start_date + weeks_remaining.weeks |
|
|
else |
|
|
else |
|
|
@estimated_end_by_typ_art[typ][art] = nil |
|
|
@estimated_end_by_typ_art[typ][art] = nil |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@actual_hours_per_week = {} |
|
|
@actual_hours_per_week = {} |
|
|
|
|
|
|
|
|
User::PRAKTIKUMSTYPEN.product(User::ENTRY_ARTEN).each do |typ, art| |
|
|
User::PRAKTIKUMSTYPEN.product(User::ENTRY_ARTEN).each do |typ, art| |
|
|
|