|
|
|
@ -22,6 +22,10 @@ class EntriesController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
@completion_percent_by_typ_art = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Verbleibende Minuten je Kombination |
|
|
|
@remaining_minutes_matrix = {} |
|
|
|
@time_by_typ_art.each do |typ, arts| |
|
|
|
@ -34,6 +38,26 @@ class EntriesController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
User::PRAKTIKUMSTYPEN.product(User::ENTRY_ARTEN).each do |typ, art| |
|
|
|
total_required = current_user.required_hours_matrix.to_h.dig(typ, art).to_f |
|
|
|
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? |
|
|
|
|
|
|
|
Rails.logger.info "=== #{art} #{typ} ===" |
|
|
|
Rails.logger.info "Erforderlich (min): #{required_minutes}, Verbleibend: #{remaining_minutes}, Einträge vorhanden? #{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 |
|
|
|
else |
|
|
|
@completion_percent_by_typ_art[[typ, art]] = 0 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@total_kilometer_costs_by_year = Entry.total_kilometer_cost_by_year(current_user) |
|
|
|
@fortbildungskosten_by_year = Entry.total_fortbildungskosten_by_year(current_user) |
|
|
|
@selbstsupervision_by_year = Entry.total_supervision_by_year(current_user) |
|
|
|
|