Class: HrLite::TeamDay

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#calendarObject (readonly)

Returns the value of attribute calendar.



19
20
21
# File 'app/services/hr_lite/team_day.rb', line 19

def calendar
  @calendar
end

#dateObject (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

#kpisObject



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

#rowsObject



21
22
23
# File 'app/services/hr_lite/team_day.rb', line 21

def rows
  @rows ||= build_rows
end