Show logged time on jobs
This commit is contained in:
parent
73d3066b74
commit
1d4744f108
|
@ -8,7 +8,13 @@ class Job < ActiveRecord::Base
|
|||
|
||||
scope :project, ->(project) { where(project_id: project.id) }
|
||||
|
||||
def time_logged
|
||||
42
|
||||
def total_time_logged
|
||||
TimeEntry.where(job_id: id)
|
||||
.sum(:hours)
|
||||
end
|
||||
|
||||
def total_time_logged_for(activity)
|
||||
TimeEntry.where(job_id: id, activity_id: activity.id)
|
||||
.sum(:hours)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
<%= f.date_field :ends_on %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.hidden_field :project_id, value: @project.id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.label :external_project_id %>
|
||||
|
|
|
@ -6,6 +6,12 @@
|
|||
<dd><%= @job.starts_on %></dd>
|
||||
<dt>Ends on:</dt>
|
||||
<dd><%= @job.ends_on %></dd>
|
||||
<dt>Total time logged:</dt>
|
||||
<dd><%= @job.total_time_logged %></dd>
|
||||
<% TimeEntryActivity.all.each do |activity| %>
|
||||
<dt>Total time logged for <%= activity.name %></dt>
|
||||
<dd><%= @job.total_time_logged_for(activity) %></dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
|
||||
<%= link_to 'Edit job', edit_job_path(@job, project_id: @project.id) %>
|
||||
|
|
Loading…
Reference in New Issue