Redmine-Jobs/app/models/job.rb

21 lines
433 B
Ruby
Raw Normal View History

2023-11-16 20:23:09 +00:00
class Job < ActiveRecord::Base
validates :starts_on,
:ends_on,
:name,
presence: true
2023-11-21 14:09:51 +00:00
belongs_to :project
2023-11-21 13:59:43 +00:00
scope :project, ->(project) { where(project_id: project.id) }
2023-11-21 14:37:11 +00:00
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)
2023-11-16 20:23:09 +00:00
end
end