Class TrackRecordReport::ReportCell
In: lib/track_record_report.rb
Parent: ReportElementaryCalculator

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:

  • The ReportCell objects are stored in a ReportRow "cells" array. The array indices correspond directly to array indices of the Report‘s "ranges" array, compiled as the first row of the report gets built.
  • The ReportRows’ "task" property gives the task object for that row.

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.

Methods

Attributes

user_data  [R]  User breakdown for this cell

Public Class methods

[Source]

      # File lib/track_record_report.rb, line 1063
1063:     def initialize()
1064:       super()
1065:       @user_data = []
1066:     end

Public Instance methods

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

[Source]

      # File lib/track_record_report.rb, line 1071
1071:     def add_user_data( data )
1072:       @user_data.push( data )
1073:       add!( data )
1074:     end

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.

[Source]

      # File lib/track_record_report.rb, line 1083
1083:     def calculate!( range, committed, not_committed, user_ids = [] )
1084:       # Reset internal calculations and pre-allocate ReportUserData objects for
1085:       # each user (if any).
1086: 
1087:       reset!()
1088:       @user_data = []
1089: 
1090:       user_ids.each_index do | user_index |
1091:         @user_data[ user_index ]= ReportUserData.new
1092:       end
1093: 
1094:       # Start and the end of the committed packets array. For anything within
1095:       # the given range, add the hours to the internal total and add to the
1096:       # relevant user
1097: 
1098:       @committed = sum(
1099:         range,
1100:         committed,
1101:         user_ids,
1102:         :add_committed_hours
1103:       )
1104: 
1105:       # Same again, but for not committed hours.
1106: 
1107:       @not_committed = sum(
1108:         range,
1109:         not_committed,
1110:         user_ids,
1111:         :add_not_committed_hours
1112:       )
1113:     end

[Validate]