class Forecast::API::Assignments

Public Instance Methods

business_days_between(date1, date2) click to toggle source
# File lib/forecast/api/assignments.rb, line 51
def business_days_between(date1, date2)
  business_days = 0
  date = date2
  while date > date1
   business_days = business_days + 1 unless date.saturday? or date.sunday?
   date = date - 1.day
  end
  business_days
end
by_project(project_id, query_options={}) click to toggle source
# File lib/forecast/api/assignments.rb, line 12
def by_project(project_id, query_options={})
  query = {project_id: project_id}.merge(query_options)
  self.all(query)
end
create(*) click to toggle source
# File lib/forecast/api/assignments.rb, line 40
def create(*) ; raise "not implemented" ; end
delete(*) click to toggle source
# File lib/forecast/api/assignments.rb, line 42
def delete(*) ; raise "not implemented" ; end
last_by_date(array_hm) click to toggle source
# File lib/forecast/api/assignments.rb, line 45
def last_by_date(array_hm)
  array_hm.sort_by do |x|
    Date.strptime(x.end_date, FORECAST_DATE_FORMAT)
  end.last
end
last_by_project(project_id) click to toggle source
# File lib/forecast/api/assignments.rb, line 34
def last_by_project(project_id)
  x = self.by_project(project_id)
  self.last_by_date(x)
end
sum_allocation_seconds(query) click to toggle source
# File lib/forecast/api/assignments.rb, line 17
def sum_allocation_seconds(query)
  axs = self.all(query)

  total_time = 0

  axs.each do |x|
    start_date = Date.strptime(x.start_date, FORECAST_DATE_FORMAT)
    end_date = Date.strptime(x.end_date, FORECAST_DATE_FORMAT)

    num_days = start_date.business_days_until(end_date) + 1

    total_time += (1.0 * x.allocation * num_days)
  end

  return total_time
end
update(*) click to toggle source
# File lib/forecast/api/assignments.rb, line 41
def update(*) ; raise "not implemented" ; end