Class: DailyFocus::DataGatherer
- Inherits:
-
Object
- Object
- DailyFocus::DataGatherer
- Defined in:
- app/services/daily_focus/data_gatherer.rb
Overview
Collects and structures CRM data for one sales rep's daily focus analysis.
Returns a Result object that can be rendered by the analysis prompt template.
Data sources:
- Today's prioritized activities (post-ActivityPrioritizationWorker)
- Recent call records with AI summaries and action items (last 3 days)
- Open opportunities sorted by stage and value
- Customer watch list signals (SPI, recent orders)
- Recent Sunny conversations (pattern/theme detection)
- Lapsed trade accounts (repeat buyers who stopped purchasing)
Defined Under Namespace
Classes: Result
Constant Summary collapse
- CALL_LOOKBACK_DAYS =
Call lookback days.
3- CONVERSATION_LOOKBACK_DAYS =
Conversation lookback days.
7- LAPSED_DAYS_THRESHOLD =
Threshold for lapsed days.
90- MAX_ACTIVITIES =
Maximum activities.
50- MAX_CALLS =
Maximum calls.
30- MAX_OPPORTUNITIES =
Maximum opportunities.
25- MAX_ORDERS =
Maximum orders.
15- MAX_CONVERSATIONS =
Maximum conversations.
5- MAX_LAPSED_ACCOUNTS =
Maximum lapsed accounts.
10- INACTIONABLE_LAPSED_STATES =
Customer lifecycle states that disqualify an account from lapsed-trade
outreach: never-real accounts (guest) and ended relationships
(closed, bankrupt, in collections, mid-merge). Recommending these wastes
rep time and drags down KPIs — see CustomerLifecycle for the full machine. %w[guest closed bankrupt sent_to_collections merging].freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(employee) ⇒ DataGatherer
constructor
A new instance of DataGatherer.
Constructor Details
#initialize(employee) ⇒ DataGatherer
Returns a new instance of DataGatherer.
66 67 68 |
# File 'app/services/daily_focus/data_gatherer.rb', line 66 def initialize(employee) @employee = employee end |
Instance Method Details
#call ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/services/daily_focus/data_gatherer.rb', line 70 def call briefing_content, briefing_date = fetch_previous_briefing Result.new( employee: @employee, date: Date.current, todays_activities: fetch_todays_activities, overdue_activities: fetch_overdue_activities, recent_calls: fetch_recent_calls, open_opportunities: fetch_open_opportunities, recent_orders: fetch_recent_orders, recent_conversations: fetch_recent_conversations, lapsed_trade_accounts: fetch_lapsed_trade_accounts, previous_briefing: briefing_content, previous_briefing_date: briefing_date ) end |