Browse Source

minor fixes

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

8
app/controllers/entries_controller.rb

@ -22,10 +22,6 @@ class EntriesController < ApplicationController
end end
end end
@completion_percent_by_typ_art = {}
# Verbleibende Minuten je Kombination # Verbleibende Minuten je Kombination
@remaining_minutes_matrix = {} @remaining_minutes_matrix = {}
@time_by_typ_art.each do |typ, arts| @time_by_typ_art.each do |typ, arts|
@ -38,6 +34,8 @@ class EntriesController < ApplicationController
end end
end end
@completion_percent_by_typ_art = {}
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
@ -61,6 +59,8 @@ 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 = {}

2
app/models/entry.rb

@ -35,7 +35,7 @@ class Entry < ApplicationRecord
.order(Arel.sql("DATE_PART('year', date) DESC")) .order(Arel.sql("DATE_PART('year', date) DESC"))
.pluck( .pluck(
Arel.sql("DATE_PART('year', date)::int"), Arel.sql("DATE_PART('year', date)::int"),
Arel.sql("SUM(distance_km * 2 * 0.42)")
Arel.sql("SUM(distance_km * 0.42)")
).to_h ).to_h
end end

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

@ -42,7 +42,7 @@
</div> </div>
<div class="col rounded border shadow-sm p-3"> <div class="col rounded border shadow-sm p-3">
<h5>📊 Gesamtkosten</h5>
<h5>📊 Gesamtkosten (Werbungskosten)</h5>
<% @allekosten_by_year.each do |year, sum| %> <% @allekosten_by_year.each do |year, sum| %>
<p><strong><%= year %>:</strong> <p><strong><%= year %>:</strong>
<%= number_to_currency(sum, unit: "€", separator: ",", delimiter: ".", precision: 2) %> <%= number_to_currency(sum, unit: "€", separator: ",", delimiter: ".", precision: 2) %>

Loading…
Cancel
Save