Class: TempestTime::Services::GenerateReport
- Inherits:
-
Object
- Object
- TempestTime::Services::GenerateReport
- Includes:
- Helpers::TimeHelper
- Defined in:
- lib/tempest_time/services/generate_report.rb
Instance Attribute Summary collapse
-
#reports ⇒ Object
readonly
Returns the value of attribute reports.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
-
#week_number ⇒ Object
readonly
Returns the value of attribute week_number.
Instance Method Summary collapse
- #aggregate ⇒ Object
- #end_date ⇒ Object
-
#initialize(users, week_number) ⇒ GenerateReport
constructor
A new instance of GenerateReport.
- #projects ⇒ Object
- #start_date ⇒ Object
Methods included from Helpers::TimeHelper
#beginning_of_this_week, #beginning_of_week, #formatted_date, #formatted_date_range, #formatted_time, #parsed_date_input, #parsed_time, #this_week
Constructor Details
#initialize(users, week_number) ⇒ GenerateReport
Returns a new instance of GenerateReport.
12 13 14 15 16 |
# File 'lib/tempest_time/services/generate_report.rb', line 12 def initialize(users, week_number) @users = users @week_number = week_number || Date.today.cweek @reports = build_reports if valid? end |
Instance Attribute Details
#reports ⇒ Object (readonly)
Returns the value of attribute reports.
10 11 12 |
# File 'lib/tempest_time/services/generate_report.rb', line 10 def reports @reports end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
10 11 12 |
# File 'lib/tempest_time/services/generate_report.rb', line 10 def users @users end |
#week_number ⇒ Object (readonly)
Returns the value of attribute week_number.
10 11 12 |
# File 'lib/tempest_time/services/generate_report.rb', line 10 def week_number @week_number end |
Instance Method Details
#aggregate ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/tempest_time/services/generate_report.rb', line 22 def aggregate @aggregate ||= TempestTime::Models::Report.new( 'TOTAL', reports.flat_map(&:worklogs), users.count ) end |
#end_date ⇒ Object
34 35 36 |
# File 'lib/tempest_time/services/generate_report.rb', line 34 def end_date @end_date ||= start_date + 6 end |
#projects ⇒ Object
18 19 20 |
# File 'lib/tempest_time/services/generate_report.rb', line 18 def projects @projects ||= reports.flat_map(&:projects).uniq end |
#start_date ⇒ Object
30 31 32 |
# File 'lib/tempest_time/services/generate_report.rb', line 30 def start_date @start_date ||= beginning_of_week(week_number) end |