Class: DailyFocus::WorkDayIndicator

Inherits:
Object
  • Object
show all
Defined in:
app/services/daily_focus/work_day_indicator.rb

Overview

Maps +Employee#work_status_on_day+ / +working_on_day?+ to two briefing-adjacent badges: "Not working" or "Partially working".

Defined Under Namespace

Classes: Result

Constant Summary collapse

PARTIAL_ICON_CLASS =
'fa-solid fa-clock me-1'
NOT_WORKING_ICON_CLASS =
'fa-solid fa-mug-hot me-1'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(employee:, date:) ⇒ WorkDayIndicator

Returns a new instance of WorkDayIndicator.



16
17
18
19
# File 'app/services/daily_focus/work_day_indicator.rb', line 16

def initialize(employee:, date:)
  @employee = employee
  @date = date
end

Class Method Details

.call(employee:, date:) ⇒ Result?

Returns nil when the rep is treated as a full working day for Daily Focus / capacity.

Returns:

  • (Result, nil)

    nil when the rep is treated as a full working day for Daily Focus / capacity.



12
13
14
# File 'app/services/daily_focus/work_day_indicator.rb', line 12

def self.call(employee:, date:)
  new(employee:, date: date.to_date).call
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/services/daily_focus/work_day_indicator.rb', line 21

def call
  return nil if show_nothing?

  if partial_day?
    Result.new(
      label: 'Partially working',
      css_class: 'bg-warning text-dark',
      title: partial_title,
      icon_class: PARTIAL_ICON_CLASS
    )
  else
    Result.new(
      label: 'Not working',
      css_class: 'bg-secondary',
      title: not_working_title,
      icon_class: NOT_WORKING_ICON_CLASS
    )
  end
end