Class: HrLite::TeamDay
- Inherits:
-
Object
- Object
- HrLite::TeamDay
- Defined in:
- app/services/hr_lite/team_day.rb
Overview
One row per staff member for a single date — powers the everyone-visible Team board: who's in, who's out, who's on leave, hours worked. Batch queries (five total, regardless of team size); the per-day precedence mirrors DayStatus (holiday > weekend > leave > punch > absent/upcoming).
Defined Under Namespace
Classes: Row
Instance Attribute Summary collapse
-
#calendar ⇒ Object
readonly
Returns the value of attribute calendar.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
Instance Method Summary collapse
-
#initialize(date: Date.current) ⇒ TeamDay
constructor
A new instance of TeamDay.
- #kpis ⇒ Object
- #rows ⇒ Object
Constructor Details
#initialize(date: Date.current) ⇒ TeamDay
Returns a new instance of TeamDay.
14 15 16 17 |
# File 'app/services/hr_lite/team_day.rb', line 14 def initialize(date: Date.current) @date = date @calendar = WorkingCalendar.new(date..date) end |
Instance Attribute Details
#calendar ⇒ Object (readonly)
Returns the value of attribute calendar.
19 20 21 |
# File 'app/services/hr_lite/team_day.rb', line 19 def calendar @calendar end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
19 20 21 |
# File 'app/services/hr_lite/team_day.rb', line 19 def date @date end |
Instance Method Details
#kpis ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/services/hr_lite/team_day.rb', line 25 def kpis { checked_in: rows.count { |r| r.record&.check_in_at }, on_leave: rows.count { |r| %i[leave half_day_leave].include?(r.kind) }, not_in: rows.count { |r| r.kind == :absent } } end |
#rows ⇒ Object
21 22 23 |
# File 'app/services/hr_lite/team_day.rb', line 21 def rows @rows ||= build_rows end |