|
|
@ -5,15 +5,17 @@ class EntriesController < ApplicationController |
|
|
def index |
|
|
def index |
|
|
@entries = current_user.entries.order(date: :desc) |
|
|
@entries = current_user.entries.order(date: :desc) |
|
|
|
|
|
|
|
|
# Nur Einträge bis einschließlich heute für Zeitberechnungen verwenden |
|
|
|
|
|
|
|
|
# Für Berechnungen nur Einträge bis einschließlich heute verwenden. |
|
|
|
|
|
# Keine Sortierung setzen, da diese Relation später unterschiedlich |
|
|
|
|
|
# ausgewertet wird. |
|
|
@calculation_entries = current_user.entries |
|
|
@calculation_entries = current_user.entries |
|
|
.where("date <= ?", Date.current) |
|
|
.where("date <= ?", Date.current) |
|
|
.order(date: :desc) |
|
|
|
|
|
|
|
|
|
|
|
@running_entry = current_user.entries.find_by( |
|
|
@running_entry = current_user.entries.find_by( |
|
|
end_time: nil, |
|
|
end_time: nil, |
|
|
beschreibung: "Timer" |
|
|
beschreibung: "Timer" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
required_hours_matrix = current_user.required_hours_matrix.to_h |
|
|
required_hours_matrix = current_user.required_hours_matrix.to_h |
|
|
weekly_target_matrix = current_user.weekly_target_matrix.to_h |
|
|
weekly_target_matrix = current_user.weekly_target_matrix.to_h |
|
|
@ -307,15 +309,17 @@ class EntriesController < ApplicationController |
|
|
.where( |
|
|
.where( |
|
|
"COALESCE(hours, 0) > 0 OR COALESCE(minutes, 0) > 0" |
|
|
"COALESCE(hours, 0) > 0 OR COALESCE(minutes, 0) > 0" |
|
|
) |
|
|
) |
|
|
.order(:date) |
|
|
|
|
|
.to_a |
|
|
|
|
|
|
|
|
|
|
|
next if entries.empty? |
|
|
|
|
|
|
|
|
next unless entries.exists? |
|
|
|
|
|
|
|
|
spent_minutes = sum_minutes(entries) |
|
|
|
|
|
|
|
|
spent_minutes = entries.sum do |entry| |
|
|
|
|
|
entry.hours.to_i * 60 + entry.minutes.to_i |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
first_entry_date = entries.minimum(:date) |
|
|
|
|
|
last_entry_date = entries.maximum(:date) |
|
|
|
|
|
|
|
|
first_entry_date = entries.first.date |
|
|
|
|
|
last_entry_date = entries.last.date |
|
|
|
|
|
|
|
|
next unless first_entry_date |
|
|
|
|
|
|
|
|
required_minutes = (required_hours * 60).round |
|
|
required_minutes = (required_hours * 60).round |
|
|
completed = spent_minutes >= required_minutes |
|
|
completed = spent_minutes >= required_minutes |
|
|
@ -332,11 +336,11 @@ class EntriesController < ApplicationController |
|
|
|
|
|
|
|
|
weeks = total_days / 7.0 |
|
|
weeks = total_days / 7.0 |
|
|
|
|
|
|
|
|
actual_hours = spent_minutes / 60.0 |
|
|
|
|
|
|
|
|
actual_hours_per_week = |
|
|
|
|
|
(spent_minutes / 60.0) / weeks |
|
|
|
|
|
|
|
|
@actual_hours_per_week[[typ, art]] = ( |
|
|
|
|
|
actual_hours / weeks |
|
|
|
|
|
).round(2) |
|
|
|
|
|
|
|
|
@actual_hours_per_week[[typ, art]] = |
|
|
|
|
|
actual_hours_per_week.round(2) |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|