Module: DailyFocus::Prompt

Extended by:
TimeOffPlannedWorkDayHelper
Defined in:
app/services/daily_focus/prompt.rb

Overview

Short user-facing prompts for tool-based Daily Focus (no pre-injected CRM dumps).

Constant Summary collapse

EXCLUDE_ETAILERS_SQL =

E-tailer / marketplace accounts (Amazon, Costco, Home Depot, Lowes/Rona, TJX, and
any other "E-commerce - *" report grouping) are excluded from Daily Focus: they
transact through established EDI, not rep nurturing, so they only add noise to a
briefing meant for professional and homeowner accounts that need human contact.
Both view_activities and view_customers expose the customer's report_grouping; the
COALESCE keeps rows whose grouping is NULL (a bare NULL NOT LIKE … would drop them).

"COALESCE(report_grouping, '') NOT LIKE 'E-commerce%'"

Class Method Summary collapse

Methods included from TimeOffPlannedWorkDayHelper

time_off_planned_work_day_planned_hours, time_off_planned_work_day_summary, time_off_planned_work_day_usual_summary

Class Method Details

.focus_date_for_conversation(conversation) ⇒ Object



16
17
18
19
20
21
22
23
# File 'app/services/daily_focus/prompt.rb', line 16

def self.focus_date_for_conversation(conversation)
  raw = conversation&.&.dig('daily_focus_date')
  return Date.current if raw.blank?

  Date.iso8601(raw.to_s)
rescue ArgumentError
  Date.current
end

.instructions_prefill(primary_employee:, covered_employees: [], date: Date.current) ⇒ Object



25
26
27
# File 'app/services/daily_focus/prompt.rb', line 25

def self.instructions_prefill(primary_employee:, covered_employees: [], date: Date.current)
  user_message(primary_employee: primary_employee, covered_employees: covered_employees, date: date)
end

.user_message(primary_employee:, covered_employees: [], date: Date.current) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/services/daily_focus/prompt.rb', line 29

def self.user_message(primary_employee:, covered_employees: [], date: Date.current)
  covered = Array(covered_employees).compact.uniq
  preload_planned_availability!([primary_employee, *covered], date)
  planned = planned_work_availability_section(
    primary_employee: primary_employee,
    covered_employees: covered,
    date: date
  )
  tz = TimezoneHints.prompt_section(primary_employee: primary_employee, covered_employees: covered)
  parts = [core_body(primary_employee, covered)]
  parts << planned if planned.present?
  parts << tz
  parts.join(' ')
end