Browse Source

add total time

main
Christoph Marzell 3 weeks ago
parent
commit
2f26983f6a
  1. 8
      app/controllers/entries_controller.rb
  2. 7
      app/views/entries/index.html.erb

8
app/controllers/entries_controller.rb

@ -8,6 +8,10 @@ class EntriesController < ApplicationController
# Gesamtzeit in Minuten
@total_minutes = @entries.sum { |e| e.hours.to_i * 60 + e.minutes.to_i }
@total_minutes_praktikum_prop = @entries.where(praktikums_typ: Entry::PRAKTIKUMSTYPEN[0], entry_art: Entry::ENTRY_ARTEN[0]).sum { |e| e.hours.to_i * 60 + e.minutes.to_i }
@total_minutes_praktikum_fach = @entries.where(praktikums_typ: Entry::PRAKTIKUMSTYPEN[1], entry_art: Entry::ENTRY_ARTEN[0]).sum { |e| e.hours.to_i * 60 + e.minutes.to_i }
# Gesamtbetrag der Kilometerpauschale
@total_kilometer_pauschale = @entries.sum(&:kilometer_pauschale)
@ -36,7 +40,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 = {}
@ -76,8 +79,6 @@ class EntriesController < ApplicationController
@entry.end_time = Time.current
@entry.lunch_break_minutes = 30 if ActiveModel::Type::Boolean.new.cast(params[:lunch_break])
total_minutes = @entry.total_minutes_including_break
@entry.hours = total_minutes / 60
@entry.minutes = total_minutes % 60
@ -159,6 +160,7 @@ class EntriesController < ApplicationController
}
end
end
private
def set_entry

7
app/views/entries/index.html.erb

@ -52,7 +52,12 @@
<div class="col rounded border shadow-sm p-3">
<h5>🕒 Gesamtzeit</h5>
<p><strong><%= @total_minutes / 60 %> h <%= @total_minutes % 60 %> min</strong></p>
<p><strong>Total: <%= @total_minutes / 60 %> <%= @total_minutes % 60 %> min</strong></p>
<p>Propädeutikum: <%= @total_minutes_praktikum_prop / 60 %> <%= @total_minutes % 60 %> min</strong></p>
<p>Fachspezifikum: <%= @total_minutes_praktikum_fach / 60 %> <%= @total_minutes % 60 %> min</strong></p>
</div>
</div>

Loading…
Cancel
Save