From 159f8c30d7452fec1c07fdf1a9375e5ccb7265a6 Mon Sep 17 00:00:00 2001 From: Christoph Marzell Date: Fri, 2 Jan 2026 12:23:04 +0100 Subject: [PATCH] add erledigt --- app/controllers/entries_controller.rb | 45 +++++++++++---------------- app/views/entries/index.html.erb | 3 ++ 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb index b71405e..90a2c6a 100644 --- a/app/controllers/entries_controller.rb +++ b/app/controllers/entries_controller.rb @@ -24,54 +24,49 @@ class EntriesController < ApplicationController # Verbleibende Minuten je Kombination @remaining_minutes_matrix = {} + @spent_minutes_matrix = {} @time_by_typ_art.each do |typ, arts| @remaining_minutes_matrix[typ] ||= {} - + @spent_minutes_matrix[typ] ||= {} arts.each do |art, spent_minutes| target = current_user.required_hours_matrix.dig(typ, art).to_i * 60 remaining = [target - spent_minutes, 0].max @remaining_minutes_matrix[typ][art] = remaining + @spent_minutes_matrix[typ][art] = spent_minutes end end @completion_percent_by_typ_art = {} - @progress_chart_data = {} + @progress_chart_data = {} @progress_colors = {} 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 - 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 - 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 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 end @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 - - - - - @total_kilometer_costs_by_year = Entry.total_kilometer_cost_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) @allekosten_by_year = Entry.total_semesterkosten_by_year(current_user) - - # Voraussichtliches Ende je Kombination basierend auf weekly_target_matrix # @estimated_end_by_typ_art = {} diff --git a/app/views/entries/index.html.erb b/app/views/entries/index.html.erb index ea63427..d79a336 100644 --- a/app/views/entries/index.html.erb +++ b/app/views/entries/index.html.erb @@ -26,6 +26,7 @@ Typ Art Verbleibend + Erledigt Soll (h) Wöchentlich Vorauss. Ende @@ -36,6 +37,7 @@ <% ["propädeutikum", "fachspezifikum"].each do |typ| %> <% ["Praktikum", "Selbsterfahrung", "Supervision"].each do |art| %> <% remaining = @remaining_minutes_matrix.dig(typ, art) %> + <% spent = @spent_minutes_matrix.dig(typ, art) %> <% soll = current_user.required_hours_matrix.dig(typ, art) %> <% weekly = current_user.weekly_target_matrix.dig(typ, art) %> <% ende = @estimated_end_by_typ_art.dig(typ, art) %> @@ -45,6 +47,7 @@ <%= typ.capitalize %> <%= art.capitalize %> <%= remaining ? "#{remaining / 60} h #{remaining % 60} min" : "—" %> + <%= spent ? "#{spent / 60} h #{spent % 60} min" : "—" %> <%= soll || "—" %> h <%= weekly || "—" %> h/Woche <%= ende.present? ? ende.strftime("%d.%m.%Y") : "—" %>