Subversion Repositories SmartDukaan

Rev

Show changed files | Details | Compare with Previous | Blame | RSS feed

Filtering Options

Rev Age Author Path Log message Diff
37729 8 h 44 m amit /trunk/ lead: one workable lead per mobile, with a 6-month supersede and an L2+ override

There was no choke point for lead creation. Ten sites did `new Lead()` across four
modules -- three in web's LeadController, two in V2FofoLeadController, three in fofo's
LeadController, one in TrialServiceImpl and one in the cron LeadSyncRunner -- and only
ONE of them (fofo /createLead) checked for an existing lead at all. Result on live data:
5,137 mobiles carrying duplicate leads over 12,156 rows, worst case 29 on one number,
and two agents unknowingly working the same shop.

THE RULE, in new LeadCreationService, which all ten now route through:

no active lead on the number -> create
active, last activity >= 6 months -> retire the old one, create the new one, SILENTLY
active, last activity < 6 months -> BLOCK; only an L2+ user may override

Active = status in (pending, followUp) AND the assignee is still an active auth_user.
Last activity = GREATEST(lead.updated/created, MAX(lead_activity.created)).

The stale branch is deliberately quiet. A shop enquiring again after six months is a
handover, not a clash, and mailing on it would train the desk to ignore the alert -- so
only a genuine collision notifies. Live split: 195 stale against 1,241 fresh, and roughly
three blocks a month.

WHY "ACTIVE" ALSO MEANS A LIVE OWNER

331 open leads are assigned to 11 DEACTIVATED accounts (157 to sm@smartdukaan.com alone,
whose newest lead is from 2022). Counting them as active would block fresh enquiries
behind an account nobody can log in to and therefore nobody can close. Requiring a live
owner defuses all 331 without retiring a single row. Retirement here is only ever
REACTIVE -- triggered by a new entry on the same number. Nothing runs on a schedule.

ASSUMPTION worth flagging: a superseded lead becomes status=notInterested (stage DROPPED)
with closure_timestamp and reason 'Superseded after 6 months inactivity', rather than a
new `expired` status. "Closed" is an explicit allow-list in the UI --
Arrays.asList(notInterested, finalized) at V2FofoLeadController:150 and fofo
LeadController:313 -- and there are ~107 references to specific LeadStatus values, so a
new enum value would make these leads vanish from BOTH the open and closed screens.
Stage DROPPED keeps the nuance (the shop never said no) and still maps to notInterested
via LeadStage.toLegacyStatus().

OVERRIDE is L2+ in ANY team, not Call Center only: Sales L1 owns 1,063 of the 1,776 open
leads, so a Call-Center-only gate would funnel every team's collisions through three
people. The MAIL still goes to Call Center L2+, resolved from cs.position at send time
rather than hardcoded. An override is a TAKEOVER -- it closes the existing lead -- because
a second live lead is the exact thing the rule exists to prevent.

UNATTENDED CALLERS (cron sync, CSV upload, trial registration, AI intake) have nobody to
offer an override to, so they use createUnattended: skip the colliding row and mail the
desk rather than throwing. CSV reports imported/duplicateSkipped/duplicateMobiles back to
the operator instead of failing the whole file over one number.

ALSO FIXES selectByMobileNumber, which called getSingleResult and therefore threw
NonUniqueResultException on any mobile with more than one lead -- GlitchTip #99 and #1359,
both still firing. It now prefers the open lead, then the most recently touched.

NOT INCLUDED, deliberately: no DB unique constraint. 10 mobiles already carry more than
one open lead and would have to be resolved by hand first, which conflicts with the
no-auto-retirement rule. The service enforces the invariant going forward.

NEEDS A DBA STEP: user.lead.mobile is unindexed on 37,580 rows, so this check is a full
scan on every create. Index DDL is in the accompanying note; it has NOT been applied.
 
37629 6 d 8 h amit /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/ feat(mail): wire inactive-recipient filter and clean hardcoded addresses

Wire MailRecipientFilter into googleMailSender and gmailRelaySender. Remove inactive/unknown addresses from recipient and access lists, fix typo addresses, bulk uploader gate to akhil.kumar, V2 brand fee gate to kamini.sharma.
 
37354 33 d 7 h aman /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ AI lead intake: pool is BGC L1 (category 20), not Sales L1 - BGC is the desk that works AI leads  
37353 33 d 7 h aman /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ AI lead intake: assign new leads to a random active Sales L1 instead of fixed auth id 53  
37130 62 d 4 h ranu /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/ rating api issue fix  
37029 76 d 7 h aman /trunk/ AI lead intake - conform to chatbot spec: accept & store 'state' (canonical, nullable) from payload; default status to 'pending' so leads land in the Open/New view (was followUp); return 401 (not 403) on bad Auth-Token; show Outlet/Shop Name column in lead search results  
37027 76 d 8 h aman /trunk/ AI leads: fix /add/lead 500 (set NOT-NULL 'state' + null-safe last_name/city/address so voice/chat leads persist instead of crashing) and add call-recording support - new user.lead.recording_url column mapped on Lead, recordingUrl accepted on AiLeadRequest and stored in aiLead(), Recording play button in lead management (main dashboard + search/closed results). Prod needs: ALTER TABLE user.lead ADD COLUMN recording_url VARCHAR(1024) NULL;  
36957 83 d 7 h aman /trunk/ Add AI assistant lead intake endpoint (POST /add/lead) tagging source=AI Assistant in Lead Management  
36930 88 d 4 h ranu /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ rbm rating weekly -> monthly  
36860 96 d 22 h ranu /trunk/ code committed by some bug fix in pjp  
36853 97 d 6 h ranu /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ code committed by some bug fix in pjp  
36827 103 d 1 h ranu /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ code committed for buy mode(v2)  
36771 110 d 1 h ranu /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/ code commit for self lead creation  
36723 116 d 8 h vikas /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ Franchise visit activity response  
36722 116 d 8 h vikas /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ Franchise visit activity response  
36678 118 d 8 h vikas /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ Checkout Error  
36677 118 d 9 h vikas /trunk/ Checkout Error  
36661 121 d 3 h vikas /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/ Location Tracking Report: Add Travel Row and added Company Office Repository Implementation  
36400 147 d 6 h amit /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/ Replace mailSender (SendGrid) with gmailRelaySender - SendGrid API key expired/revoked  
36336 152 d 9 h ranu /trunk/ sales dispostion updated  

Show All