Subversion Repositories SmartDukaan

Rev

Show changed files | Directory listing | RSS feed

Filtering Options

Rev Age Author Path Log message Diff
37674 30 m amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/service/ Hold the browser lane around the knowlarity scrapes

These run Chrome inside the tomcat JVM, on the same box as the cron jar's
oppo/realme imei lane, with nothing coordinating the two. isScraping only guards
this JVM and cannot see the cron's driver, so the interlock has to be the
OS-level one -- BrowserLane, common r37672.

Fifteen minutes rather than the cron side's five: the insights scrape runs only
8 times a day against a lane that is busy ~96% of the time, so a short timeout
here would mean the insights never refreshed. On contention it serves cache.

The break-log scraper takes the lane around its freshDriver, which has a clean
try/finally bracket. setupDriver()'s long-lived field driver is deliberately left
alone -- its lifetime spans init to @PreDestroy and holding an OS lock that long
would starve the imei lane.
 
37673 30 m amit /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/ Hold the browser lane around the oppo/realme/motorola drivers

Takes BrowserLane (common r37672) before new ChromeDriver and releases it after
quit() returns -- the 850MB is resident for the whole chunk, not just at
startup, so bracketing only the constructor would protect nothing.

Five minutes of waiting, then give up and return what we have: the only things
that can hold the lane that long are the other brand mid-chunk or the knowlarity
scrape in the fofo tomcat, and giving up costs nothing because an unstamped imei
stays pending and the lane's next turn picks it up.

CheckMotorolaWarrantyTask carries a comment saying 'do not let this job overlap
the oppo/realme window' that nothing ever enforced. It is wired here too so it is
already safe whenever it gets a trigger -- it still has none today.

Note on sizing, since the obvious knob is the wrong one: shrinking CHUNK from 25
was evaluated and rejected. The idle window is a fixed 20s bolted onto a variable
work period, so 25->10 moves the duty cycle only 96% -> 91% while costing 8.4%
of daily throughput and 2.5x the driver launches. The lever for duty cycle is the
fixedDelay gap, not the chunk size.
 
37672 30 m amit /trunk/profitmandi-common/src/main/java/com/spice/profitmandi/common/util/ Add BrowserLane: machine-wide interlock so only one headless Chrome runs at a time

Every ChromeDriver tree on the app box costs ~850MB RSS, on a host holding a
-Xmx8g tomcat and a -Xmx2g cron jar on 16GB that has been kernel-OOM-killed
twice with tomcat the victim. Peak concurrent drivers is the number that
matters, not drivers per day.

Measured on the oppo/realme lane: a 25-imei chunk takes 505s (12s driver
startup, then ~19.7s an imei) against a fixed 20s fixedDelay, i.e. a 96% duty
cycle. Meanwhile tomcat starts its own driver 8 times a day for the knowlarity
scrape. On 17-Sep that scrape ran 11:40:00-11:41:07 and the lane's next driver
came up at 11:42:21 -- it cleared by 74 seconds, by luck. At a 96% duty cycle
the collision cannot be dodged by choosing better times, only by serialising.

The two JVMs are separate processes owned by different users, so an in-process
flag cannot see across the boundary. Uses an OS file lock at
/var/lock/sd-browser.lock (overridable via -Dsd.browser.lock), created 0666 on
first use because cron runs as root and tomcat as tomcat and whichever starts
first creates it. A file lock rather than a marker file so the kernel reclaims
it when the holder dies: verified by SIGKILLing the holder mid-hold, the next
JVM acquired in 264ms. A ReentrantLock gates it first, since a second thread in
the same JVM would otherwise get OverlappingFileLockException rather than block.

Callers wait rather than skip. The knowlarity scrape needs 67s against a lane
busy 96% of the time, so skip-on-contention would mean it essentially never
refreshed again. Eight scrapes a day costs the imei lane about nine minutes of
waiting in total.

Fails open if the lock file is unusable (missing /var/lock, read-only mount, dev
laptop): serialising within the JVM only, rather than stopping imei activation
over what is a safety interlock.
 
37671 2 h 10 m ranu /trunk/ loi revival process modify  
37670 17 h 13 m amit /trunk/profitmandi-fofo/src/main/ Check GSTIN shape on the onboarding screen before submit (jsVersion 425)

Both GST boxes are validated client-side and must match, so ops see the problem on the screen
instead of discovering it when NIC refuses the first invoice. Server-side guard in dao r37669
is what actually enforces it.
 
37669 17 h 13 m amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/user/ Reject an invalid or mismatched partner GSTIN before it is saved

The onboarding screen carries the GSTIN in two boxes both labelled GST NUMBER - the retailer
one (dtr.retailer.number) and the store one (fofo_store.gst_number, which billing reads).
Neither was validated, so DLSH1660 was saved with the LOI's pincode in the store box while the
retailer box held the real GSTIN, and its first invoice would have been refused by NIC.

validateGstNumbers runs before any write (covers the fofo portal, the V2 API and the partner
app, which all funnel through updateRetailerDetails): both values are normalised, both must be
valid GSTINs, and when both are present they must agree - across 1,800 partners on record they
already do, bar the one that caused this. Needs common r37668.
 
37668 17 h 13 m amit /trunk/profitmandi-common/src/main/ Validate GSTIN shape, state code and checksum

isValidGstNumber accepted any 15-character string, so a pincode (110095, rejected only for
length) and junk (Hdjiekwbdbsjskz) reached fofo_store.gst_number, which billing sends to NIC
as the recipient - the invoice is then refused and the goods cannot ship.

Now: 2-digit state code + PAN + entity + Z + mod-36 check digit, trimmed and upper-cased.
Blank still passes (the field is optional); callers needing one present check that themselves.
Checked against live data: 1,569 of 1,570 well-formed partner GSTINs pass, the one that fails
(HRSP330) has a genuinely wrong check digit.

Adds RTLR_1020 / RTLR_1021 for the invalid and mismatched cases.
 
37667 18 h 21 m amit /trunk/profitmandi-dao/src/main/resources/sql/ chore(sql): drop vendor catalog pricing for supplier 1 Hotspot, flagged internal 2026-09-16 (as run on prod; backups _bak_vcp/_vcpl_internal_hotspot_20260916)  
37666 18 h 46 m amit /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ Hot Deal brand: /fofo/hotDeals/brands accepts categoryId, so the brand chips match the active tab  
37665 18 h 46 m amit /trunk/profitmandi-common/src/main/java/com/spice/profitmandi/common/solr/ Hot Deal brand: optional categoryId on the brand facet, so the chips can be scoped to one tab  
37664 18 h 54 m ranu /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/user/ loi new revival process  
37663 19 h 23 m vikas /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ Added exception to method sign  
37662 19 h 30 m vikas /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/lms/ LMS click to call  
37661 19 h 33 m amit /trunk/profitmandi-common/src/main/java/com/spice/profitmandi/common/web/client/ Fix trunk: RestClient was left behind by r37655

r37655 deleted MandiiResponse but omitted RestClient from the commit, so
trunk did not compile - RestClient still imported the deleted class.

RestClient now uses RawHttpResponse: executeMandii is renamed executeRaw and
postWithResponse returns the new type. The dead getMandii helper is removed;
its only caller was MandiiService.
 
37660 19 h 52 m ranu /trunk/ ticket download option given and some enhancement on notification panel  
37659 20 h 21 m amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/ Remove the Mandii callback from fofo (r37655)

Drops the /mandii payment-notification stub from HdfcPaymentController - it
only logged the body - and its three entries in the WebConfig auth whitelist.
PartnerOnBoardingPanelController imports follow services.mandii ->
services.kyc for Gender/MaritalStatus/AddressProofType.
 
37658 20 h 28 m amit /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/ Remove Mandii onboarding tasks from cron (r37655)

RunOnceTasks loses mandiiUser/mandiiUsers, their setCreditAccount helper and
the now-unused encodeFileToBase64Binary, plus the MandiiService autowire -
133 lines that pushed partner KYC into Mandii and wrote back MANDII credit
accounts. The matching --mandiiUser / --mandiiUsers CLI options are dropped
from Application. ScheduledTasks had an unused MandiiService field.
OnBoardingRelatedSchelduleTask imports follow services.mandii -> services.kyc.
 
37657 20 h 28 m amit /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/ Remove Mandii checkout, status and callback paths (r37655)

OrderController: the paymentOption MANDII branch and createMandiiOrder are
gone. GatewayController: the MANDII branch of payment/gateway/status is gone;
the SDDIRECT branch it sat in front of is untouched and still returns
AccountStatusResponseOut.

API endpoints removed, all of them Mandii-only:
- /cart/payment (CartController + its V2CartController delegate) existed
solely to poll Mandii for an order status and credit the wallet. It called
mandiiService unconditionally, so it already failed for any other gateway.
- /mandii, the payment-notification callback, a no-op logging stub in both
HdfcPaymentController and V2FofoHdfcPaymentController, and dropped from the
WebConfig auth whitelist in the fofo commit.

V2 twins touched only where they would otherwise keep a dead route alive or
fail to compile.
 
37656 20 h 28 m amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Point dao at the relocated KYC and SD Credit types (r37655)

Imports follow services.mandii -> services.kyc / services.sdcredit, and
RecordingService takes RawHttpResponse in place of MandiiResponse.

Gateway.MANDII is kept, with a comment saying why: it is persisted as a
string on FofoPayment.gateway and CreditAccount.gateway, and 740 historical
fofo.payment rows still carry it - removing the constant would make
Hibernate throw when reading them.
 
37655 20 h 28 m amit /trunk/profitmandi-common/src/main/java/com/spice/profitmandi/common/ Remove the dead Mandii BNPL integration (common)

Mandii has taken no payment since 2022-08-23 and holds no credit account, so
MandiiService and the 29 classes only it used are deleted.

The package had become a home for live types, which are moved out rather than
lost: Gender/MaritalStatus/AddressProofType -> services.kyc (they back
@Enumerated columns on user.fofo_kyc, 317 rows), and the SD Credit account
status model - AccountStatusResponseOut and its 10 dependencies ->
services.sdcredit, still served by GatewayController for SDDIRECT.

MandiiResponse was a generic body+status holder named after the integration;
renamed RawHttpResponse, still used by RestClient for Kommuno recordings.
Its dead getMandii() helper is gone. AccountStatusResponseOut no longer
carries the hardcoded merchant.mandii.com URL it shipped to the app.

FundfinaService was logging under MandiiService.class - fixed.
 

Show All