class TrackRecordReport::ReportCell

Store information about a specific task over a column’s date range.

The object does not store the task or range data since this would be redundant across potentially numerous instances leading to significant RAM wastage. Instead:

So - to find task and range, you need to know the row index of the ReportRow and the column index of the ReportCell this contains.

Attributes

user_data[R]

User breakdown for this cell

Public Class Methods

new() click to toggle source
# File lib/track_record_report.rb, line 1112
def initialize()
  super()
  @user_data = []
end

Public Instance Methods

add_user_data( data ) click to toggle source

Add the given ReportUserData object to the “@#user_data” array and add it to the internal running hourly count.

# File lib/track_record_report.rb, line 1120
def add_user_data( data )
  @user_data.push( data )
  add!( data )
end
calculate!( range, committed, not_committed, reportable_user_ids = [] ) click to toggle source

Pass a date range, an array of committed work packets sorted by date descending, an array of not committed work packets sorted by date descending and an optional user IDs array. Hours are summed for work packets across the given range. Any work packets falling within the range are removed from the arrays. Separate totals for each of the users in the given array are maintained in the @#user_data array.

# File lib/track_record_report.rb, line 1132
def calculate!( range, committed, not_committed, reportable_user_ids = [] )
  # Reset internal calculations and pre-allocate ReportUserData objects for
  # each user (if any).

  reset!()
  @user_data = []

  reportable_user_ids.each_index do | user_index |
    @user_data[ user_index ]= ReportUserData.new
  end

  # Start and the end of the committed packets array. For anything within
  # the given range, add the hours to the internal total and add to the
  # relevant user

  @committed = sum(
    range,
    committed,
    reportable_user_ids,
    :add_committed_hours
  )

  # Same again, but for not committed hours.

  @not_committed = sum(
    range,
    not_committed,
    reportable_user_ids,
    :add_not_committed_hours
  )
end