Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Show changed files | Directory listing | RSS feed

Filtering Options

Rev Age Author Path Log message Diff
35464 136 d 12 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/ Optimize /getActivatedModelByBrand and related activation queries

- Add date range filtering in WHERE clause to use activation_timestamp index
- Replace concat(year,month) with direct date comparisons for better performance
- Optimize getAuthFofoIds to avoid unnecessary DB call when user found in cache
- Use anyMatch() instead of filter().count() for short-circuit evaluation
 
35463 136 d 13 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/ Optimize /getMobileBrandWise and /getMobileLMSGraph queries

- Replace concat(year(), month()) pattern with date range comparisons
- Enables index usage on create_timestamp and activation_timestamp columns
- Update repository methods to pass date range parameters instead of string patterns
 
35462 136 d 14 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ Fix LockAcquisitionException: Use bulk partner type fetch in controllers

Use getTypesForFofoIds() bulk method to avoid N+1 queries in:
- IndentController
- PlacementPlanController
- OrderManagementController
 
35461 136 d 14 h amit /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/ Fix LockAcquisitionException: Use bulk partner type fetch in ScheduledTasks

Use getTypesForFofoIds() bulk method in rollOutUpgardedMargins to avoid N+1 queries
 
35460 136 d 14 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Fix LockAcquisitionException: Add bulk partner type fetch with MAX(base, current_sales) logic

Problem:
- N+1 queries calling getTypeOnDate caused concurrent persist operations
- This led to LockAcquisitionException during high concurrency

Solution:
- Add getTypesForFofoIds() bulk read method for N+1 scenarios
- Add getBaseTypesForFofoIds() to fetch base types (first record of month)
- Implement MAX(base, current_sales) logic:
- Partner can upgrade mid-month based on current sales
- Partner can downgrade from upgrade but NOT below base
- Base type = previous month's sales tier
- Reduce cache from 1 day to 30 minutes for faster upgrade propagation
 
35459 136 d 20 h amit /trunk/ Revert non-Java file changes from r35458  
35458 136 d 21 h amit /trunk/ Revert @Transactional(readOnly=true) - keep @Transactional only at Controller level

Changes:
- profitmandi-web: Controllers use @Transactional(rollbackFor = Throwable.class) at class level, removed method-level @Transactional(readOnly = true)
- profitmandi-fofo: Controllers use @Transactional(rollbackFor = Throwable.class) at class level, removed method-level @Transactional
- profitmandi-dao: Removed @Transactional from services/repositories

Exceptions (called from interceptors, need own transaction):
- RoleManager: @Transactional(readOnly = true) - called from interceptor for auth
- PartnerTypeChangeServiceImpl.getBestPartner(): @Transactional - called from JWTUtil via interceptor

Fixed javax.transaction.Transactional to org.springframework.transaction.annotation.Transactional
Fixed rollbackOn to rollbackFor for Spring compatibility
 
35457 136 d 21 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/fofo/ Fixed method thats not readonly  
35456 136 d 21 h amit /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ Fixed method thats not readonly  
35455 137 d 0 h ranu /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/checkout/ order controller @Transaction roll back for current  
35454 137 d 1 h amit /trunk/ perf: Optimize N+1 queries and reduce stream iterations in today_po and today_po_rbm endpoints

MonitorController.java:
- Consolidate 12 stream ops on rbmArrViewModels into single loop
- Consolidate 6 stream ops on sold15daysOldAgingModels into single loop
- Consolidate 6 stream ops on weeklyBillingData into single loop
- Merge double iteration loops into single pass operations
- Replace containsKey+get patterns with computeIfAbsent/getOrDefault
- Add extractRbmNames() helper to eliminate duplicated stream operations

CsServiceImpl.java:
- Fix N+1 in getAuthUserIdAndAuthUserMap using batch selectByIds
- Fix N+1 in getTicketIdAndAuthUserMapUsingTickets using batch selectByIds
- Fix N+1 in getAuthUserIdAndAuthUserMapUsingPositions using batch selectByIds
- Fix N+1 in getCategoryIdAndCategoryUsingPositions using batch selectAll
- Fix N+1 in getRegionIdAndRegionMap using batch selectAll
- Fix N+1 in getAuthUserByPartnerId using batch selectByIds
- Fix double N+1 in getAuthUserAndEsclationTypeByPartnerId
- Fix N+1 in authUserpartnerIdMap using selectByPositionIds
- Fix N+1 in getAuthUserIdPartnerIdMappingByCatIds
- Fix N+1 in getAuthUserIdPartnerIdMapping

RbmTargetServiceImpl.java:
- Fix O(n*m) stream filter in getRbmTodayArr using pre-built lookup maps
- Fix O(n*m) stream filter in setMovementWiseRbmTargets using pre-built maps

today_po.vm:
- Optimize template lookups with single get instead of containsKey+get
 
35453 137 d 2 h amit /trunk/ Optimize /indent/today_po_rbm endpoint - reduce DB queries by ~99%

- Consolidate 5 weekly billing queries into 1 using SQL CASE statements
- Add RbmWeeklyBillingModel for consolidated weekly billing data
- Batch fetch partner collection remarks to avoid N+1 queries
- Batch fetch collection map for all fofoIds to avoid N+1 queries in nested loop
- Reduces ~1160 queries to ~10 queries for 50 RBMs
 
35452 137 d 4 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ Fixed npe issue and performance issue  
35451 137 d 5 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ Fixed  
35450 137 d 18 h amit /trunk/profitmandi-fofo/src/main/resources/META-INF/ Fixed  
35449 137 d 18 h amit /trunk/profitmandi-dao/src/main/resources/ Add missing think.walnut.digital.recharge.balance.url property to shared properties  
35448 137 d 18 h amit /trunk/profitmandi-web/src/main/resources/META-INF/ Add missing think.walnut.digital.recharge.balance.url property to all environments  
35447 137 d 21 h amit /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/ Fix N+1 query in refundDnAmount() - batch fetch TagListings  
35446 137 d 21 h amit /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/ Use selectAllByItems() to avoid duplicate item fetch in checkfocusedModelInPartnerStock

- Pass pre-fetched items to tagListingRepository.selectAllByItems()
- Eliminates redundant itemRepository.selectAllByCatalogIds() call

🤖 Generated with Claude Code
 
35445 137 d 21 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/catalog/ Add selectAllByItems() to avoid duplicate item fetch in tagListingRepository

- Added selectAllByItems(List<Item>) method to TagListingRepository
- Refactored selectAllByCatalogIds() to use selectAllByItems() internally
- Eliminates redundant item fetch when items are already available

🤖 Generated with Claude Code
 

Show All