Class: DailyFocus::ReviewCounts
- Inherits:
-
Object
- Object
- DailyFocus::ReviewCounts
- Defined in:
- app/services/daily_focus/review_counts.rb
Overview
Aggregates Daily Focus review stats for the same population as the review table:
active sales reps only (excludes briefings tied to inactive reps).
"Missing" counts only reps who are expected to work that day (+working_on_day?+) but have no satisfied briefing.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(date, employees: nil) ⇒ ReviewCounts
constructor
A new instance of ReviewCounts.
- #to_h ⇒ Object
Constructor Details
#initialize(date, employees: nil) ⇒ ReviewCounts
Returns a new instance of ReviewCounts.
12 13 14 15 |
# File 'app/services/daily_focus/review_counts.rb', line 12 def initialize(date, employees: nil) @date = date @employees = employees end |
Class Method Details
.call(date, employees: nil) ⇒ Object
8 9 10 |
# File 'app/services/daily_focus/review_counts.rb', line 8 def self.call(date, employees: nil) new(date, employees: employees).to_h end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/daily_focus/review_counts.rb', line 17 def to_h employees = @employees || default_employees rep_ids = employees.map(&:id) return zero_hash if rep_ids.empty? rep_id_set = rep_ids.to_set DailyFocus::ReviewWorkDayPreloader.call(employees, @date) satisfied = satisfied_rep_ids(rep_id_set) { processing: count_processing(rep_ids), pending: count_pending(rep_ids), approved: count_approved(rep_ids), missing: missing_expecting_briefing_count(employees, satisfied) } end |