|
|
@ -24,54 +24,49 @@ class EntriesController < ApplicationController |
|
|
|
|
|
|
|
|
# Verbleibende Minuten je Kombination |
|
|
# Verbleibende Minuten je Kombination |
|
|
@remaining_minutes_matrix = {} |
|
|
@remaining_minutes_matrix = {} |
|
|
|
|
|
@spent_minutes_matrix = {} |
|
|
@time_by_typ_art.each do |typ, arts| |
|
|
@time_by_typ_art.each do |typ, arts| |
|
|
@remaining_minutes_matrix[typ] ||= {} |
|
|
@remaining_minutes_matrix[typ] ||= {} |
|
|
|
|
|
|
|
|
|
|
|
@spent_minutes_matrix[typ] ||= {} |
|
|
arts.each do |art, spent_minutes| |
|
|
arts.each do |art, spent_minutes| |
|
|
target = current_user.required_hours_matrix.dig(typ, art).to_i * 60 |
|
|
target = current_user.required_hours_matrix.dig(typ, art).to_i * 60 |
|
|
remaining = [target - spent_minutes, 0].max |
|
|
remaining = [target - spent_minutes, 0].max |
|
|
@remaining_minutes_matrix[typ][art] = remaining |
|
|
@remaining_minutes_matrix[typ][art] = remaining |
|
|
|
|
|
@spent_minutes_matrix[typ][art] = spent_minutes |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
@completion_percent_by_typ_art = {} |
|
|
@completion_percent_by_typ_art = {} |
|
|
@progress_chart_data = {} |
|
|
|
|
|
|
|
|
@progress_chart_data = {} |
|
|
|
|
|
|
|
|
@progress_colors = {} |
|
|
@progress_colors = {} |
|
|
|
|
|
|
|
|
User::PRAKTIKUMSTYPEN.product(User::ENTRY_ARTEN).each do |typ, art| |
|
|
User::PRAKTIKUMSTYPEN.product(User::ENTRY_ARTEN).each do |typ, art| |
|
|
total_required = current_user.required_hours_matrix.to_h.dig(typ, art).to_f |
|
|
|
|
|
|
|
|
total_required = current_user.required_hours_matrix.to_h.dig(typ, art).to_f |
|
|
remaining_minutes = @remaining_minutes_matrix.dig(typ, art).to_i |
|
|
remaining_minutes = @remaining_minutes_matrix.dig(typ, art).to_i |
|
|
required_minutes = (total_required * 60).to_i |
|
|
|
|
|
entries_exist = current_user.entries.where(praktikums_typ: typ, entry_art: art).exists? |
|
|
|
|
|
|
|
|
required_minutes = (total_required * 60).to_i |
|
|
|
|
|
entries_exist = current_user.entries.where(praktikums_typ: typ, entry_art: art).exists? |
|
|
|
|
|
|
|
|
if total_required > 0 && entries_exist |
|
|
if total_required > 0 && entries_exist |
|
|
done_minutes = required_minutes - remaining_minutes |
|
|
|
|
|
percent = (done_minutes / required_minutes.to_f * 100).round |
|
|
|
|
|
percent = 100 if percent > 100 |
|
|
|
|
|
@completion_percent_by_typ_art[[typ, art]] = percent |
|
|
|
|
|
|
|
|
done_minutes = required_minutes - remaining_minutes |
|
|
|
|
|
percent = (done_minutes / required_minutes.to_f * 100).round |
|
|
|
|
|
percent = 100 if percent > 100 |
|
|
|
|
|
@completion_percent_by_typ_art[[typ, art]] = percent |
|
|
@progress_chart_data["#{typ.capitalize} – #{art}"] = percent |
|
|
@progress_chart_data["#{typ.capitalize} – #{art}"] = percent |
|
|
else |
|
|
else |
|
|
percent = 0 |
|
|
|
|
|
@completion_percent_by_typ_art[[typ, art]] = percent |
|
|
|
|
|
|
|
|
percent = 0 |
|
|
|
|
|
@completion_percent_by_typ_art[[typ, art]] = percent |
|
|
@progress_chart_data["#{typ.capitalize} – #{art}"] = percent |
|
|
@progress_chart_data["#{typ.capitalize} – #{art}"] = percent |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
@progress_colors["#{typ.capitalize} – #{art}"] = if percent < 50 |
|
|
@progress_colors["#{typ.capitalize} – #{art}"] = if percent < 50 |
|
|
'#007bff' # Blau |
|
|
|
|
|
elsif percent < 90 |
|
|
|
|
|
'#28a745' # Grün |
|
|
|
|
|
else |
|
|
|
|
|
'#dc3545' # Rot |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'#007bff' # Blau |
|
|
|
|
|
elsif percent < 90 |
|
|
|
|
|
'#28a745' # Grün |
|
|
|
|
|
else |
|
|
|
|
|
'#dc3545' # Rot |
|
|
|
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@total_kilometer_costs_by_year = Entry.total_kilometer_cost_by_year(current_user) |
|
|
@total_kilometer_costs_by_year = Entry.total_kilometer_cost_by_year(current_user) |
|
|
@fortbildungskosten_by_year = Entry.total_fortbildungskosten_by_year(current_user) |
|
|
@fortbildungskosten_by_year = Entry.total_fortbildungskosten_by_year(current_user) |
|
|
@ -79,8 +74,6 @@ class EntriesController < ApplicationController |
|
|
@selbsterfahrungskosten_by_year = Entry.total_selbsterfahrungskosten_by_year(current_user) |
|
|
@selbsterfahrungskosten_by_year = Entry.total_selbsterfahrungskosten_by_year(current_user) |
|
|
@allekosten_by_year = Entry.total_semesterkosten_by_year(current_user) |
|
|
@allekosten_by_year = Entry.total_semesterkosten_by_year(current_user) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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 = {} |
|
|
|