diff --git a/app/models/job.rb b/app/models/job.rb index 7df26bf..c7c474a 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -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 diff --git a/app/views/jobs/_form.html.erb b/app/views/jobs/_form.html.erb index 64afb95..ba87b6f 100644 --- a/app/views/jobs/_form.html.erb +++ b/app/views/jobs/_form.html.erb @@ -20,9 +20,7 @@ <%= f.date_field :ends_on %>
-<%= f.hidden_field :project_id, value: @project.id %> -
<%= f.label :external_project_id %> diff --git a/app/views/jobs/show.html.erb b/app/views/jobs/show.html.erb index 407e651..93f2765 100644 --- a/app/views/jobs/show.html.erb +++ b/app/views/jobs/show.html.erb @@ -6,6 +6,12 @@