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 =
3- CONVERSATION_LOOKBACK_DAYS =
7- LAPSED_DAYS_THRESHOLD =
90- MAX_ACTIVITIES =
50- MAX_CALLS =
30- MAX_OPPORTUNITIES =
25- MAX_ORDERS =
15- MAX_CONVERSATIONS =
5- MAX_LAPSED_ACCOUNTS =
10
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.
51 52 53 |
# File 'app/services/daily_focus/data_gatherer.rb', line 51 def initialize(employee) @employee = employee end |
Instance Method Details
#call ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/services/daily_focus/data_gatherer.rb', line 55 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 |