Skip to content

Release 3.7.1 to main#140

Open
snehar-nd wants to merge 38 commits into
mainfrom
release-3.7.1
Open

Release 3.7.1 to main#140
snehar-nd wants to merge 38 commits into
mainfrom
release-3.7.1

Conversation

@snehar-nd

@snehar-nd snehar-nd commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

📋 Description

JIRA ID:

Please provide a summary of the change and the motivation behind it. Include relevant context and details.


✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.

Summary by CodeRabbit

  • New Features

    • Added a 5 MB maximum file-size limit for Base64-encoded Excel uploads.
    • Removed the previous 1,000-row upload restriction.
  • Bug Fixes

    • Improved outbound call eligibility and allocation counts.
    • Preserved allocation details when calls end for specified unanswered-call reasons.
    • Improved handling of call status and scheduling conditions.
  • Release

    • Updated the application version to 3.7.1.

snehar-nd and others added 30 commits February 4, 2026 14:28
fix: amm-2140 stillbirth and abortion report download issue
Upgrade version from 3.6.0 to 3.7.0
fix: amm-2140 baby death report download issue
Reassign calls from MO to ANM and display HRP in ANM worklist
changes made for disconnected call and call allocation
When a call is closed with a not-answered reason (Number busy, Switched off,
No reply, etc.), the call was being unallocated from the agent due to
isCallDisconnected being forced true. This fix restores the agent allocation
so the record stays visible in the agent's worklist for retry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Roshini's change unallocated ALL disconnected calls including busy ones.
Fixed at root cause - unallocation now skipped when reason is a
not-answered type (busy, switched off, no reply etc).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: busy/not-answered calls stay in agent worklist after call closure
Adds composite DB indexes on t_mctsoutboundcalls, t_childvaliddata, and
t_mothervalidrecord to fix the 504 Gateway Timeout on the Child+Self
call allocation info endpoint. Existing single-column indexes on low-
cardinality columns (phoneNumberType=2, ProviderServiceMapID=2) were
being skipped by the MySQL optimizer, causing full scans of 4M+ rows.

Run db_indexes_performance.sql directly on production DB — no deployment needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ordsInfo

The Child+Self call allocation info endpoint timed out (504) because
getEligibleRecordsInfo fired 3 separate COUNT queries against
t_mctsoutboundcalls (4M rows) sequentially — each doing a full table
scan. Q3 (HR unallocated) returned 0 rows but still scanned all 4M rows.

Fix: replace the 3 separate queries with a single native SQL query using
SUM(CASE WHEN) conditional aggregation. One table scan now returns all
three counts (LR unallocated, HR unallocated, allocated) instead of three
independent scans. Same fix applied to the Mother path.

Combined with composite DB indexes in db_indexes_performance.sql, this
reduces response time from 60s+ timeout to under 1s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y migration

Indexes belong in the DB migration repo, not the application repo.
See AMRIT-DB V83__ECD_outbound_calls_performance_indexes.sql.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o fix 504

Converts getChildUnAllocatedCountLR, getChildUnAllocatedCountHR, and
getTotalAllocatedCountChild to native queries with FORCE INDEX hint so
MySQL uses the correct index instead of doing a full scan of 4M rows.

Reverts consolidated SUM(CASE WHEN) approach — back to 3 separate queries,
each now guided to idx_mcts_eligible_v2 via FORCE INDEX.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…k to 3 separate calls

Removes unused getChildCountsLRHRAllocated and getMotherCountsLRHRAllocated
from OutboundCallsRepo. Reverts mother count block in CallAllocationImpl
to use the original 3 separate query methods.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Addresses reviewer comment: use OutboundCalls entity and mapped field names
instead of raw table/column names with FORCE INDEX. Performance is handled
by the restructured idx_mcts_eligible_v2 index (AMRIT-DB V84 migration).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sneha and others added 7 commits June 29, 2026 15:20
…o fix 504

Reverts JPQL queries back to native SQL with FORCE INDEX hint on
getChildUnAllocatedCountLR, getChildUnAllocatedCountHR, and
getTotalAllocatedCountChild. FORCE INDEX is required to guarantee MySQL
uses idx_mcts_eligible_v2 (restructured via AMRIT-DB V84 migration)
instead of falling back to a full table scan on 4M+ rows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…bleRecordsInfo

Fix/504 composite indexes get eligible records info
Bump version from 3.7.0 to 3.7.1
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR updates outbound-call allocation count queries, conditional call-closure resets, Excel upload size validation, and the Maven project version.

Changes

Allocation and upload behavior

Layer / File(s) Summary
Native allocation count queries
src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java, src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java
Three count queries now use native SQL with indexed table access, while allocation totals use shared status constants.
Conditional call allocation reset
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java
Disconnected-call allocation fields are reset only for applicable call-not-answered reasons.
Decoded upload size validation
src/main/java/com/iemr/ecd/service/data_upload/RCHDataUploadServiceImpl.java
Decoded Excel uploads are limited to 5MB, and the previous 1,000-row rejection is removed.

Release metadata

Layer / File(s) Summary
Maven project version
pom.xml
The project version changes from 3.7.0 to 3.7.1.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: vanitha1822

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title correctly identifies this PR as the 3.7.1 release being merged to main.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
pom.xml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-authored-by: Sneha <sneha@ADMINs-MacBook-Pro.local>
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/iemr/ecd/service/data_upload/RCHDataUploadServiceImpl.java`:
- Around line 85-88: Reinstate a maximum row-count validation in the workbook
processing flow of RCHDataUploadServiceImpl after opening the workbook and
before creating or retaining MotherRecord/ChildRecord entities. Enforce a
reasonable limit of 5,000–10,000 rows, reject oversized workbooks with an
ECDException, and preserve the existing file-size validation and saveAll
behavior for valid inputs.
- Around line 85-88: Move the size validation in the RCH data upload flow to the
Base64 input before Base64.decodeBase64 executes. Estimate the decoded byte
length from the encoded payload, account for padding as needed, and throw the
existing ECDException when the estimate exceeds MAX_FILE_SIZE_BYTES; retain the
post-decode check only if needed for exact validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7f6e420-4e5a-4884-8cc0-9749bddd5bfd

📥 Commits

Reviewing files that changed from the base of the PR and between bedd90a and 5390795.

📒 Files selected for processing (5)
  • pom.xml
  • src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java
  • src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java
  • src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java
  • src/main/java/com/iemr/ecd/service/data_upload/RCHDataUploadServiceImpl.java

Comment on lines +85 to +88

if (excelDataBytes.length > MAX_FILE_SIZE_BYTES)
throw new ECDException("File size exceeds the maximum allowed limit of 5MB");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Reinstate a row count validation limit to prevent memory exhaustion.

Relying solely on a 5MB file-size limit introduces a severe memory exhaustion (OOM) vulnerability. Because .xlsx files are highly compressed ZIP archives, a 5MB file can easily contain hundreds of thousands of rows.

Processing and retaining this many MotherRecord or ChildRecord entities in memory to persist them in a single JPA saveAll batch will likely cause heap exhaustion or database transaction timeouts. Please reinstate a reasonable row count validation (e.g., 5,000 to 10,000 rows max) after opening the workbook to safeguard system stability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/iemr/ecd/service/data_upload/RCHDataUploadServiceImpl.java`
around lines 85 - 88, Reinstate a maximum row-count validation in the workbook
processing flow of RCHDataUploadServiceImpl after opening the workbook and
before creating or retaining MotherRecord/ChildRecord entities. Enforce a
reasonable limit of 5,000–10,000 rows, reject oversized workbooks with an
ECDException, and preserve the existing file-size validation and saveAll
behavior for valid inputs.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Fast-fail on oversized Base64 payloads before decoding.

Validating the file size only after Base64.decodeBase64 executes allows exceptionally large payloads to allocate massive byte arrays in memory, leading to unnecessary CPU cycles and a potential OutOfMemoryError (OOM) before the size limit safeguard is even reached.

Check the estimated length of the Base64 string before decoding to safely fail fast.

⚡ Proposed optimization
 				String base64File = rchFileUploadDto.getFileContent();
+
+				// Fast-fail on absurdly large payloads to prevent OOM during decoding.
+				// A Base64 string's length is roughly 4/3 of the decoded byte array.
+				if (base64File.length() > MAX_FILE_SIZE_BYTES * 2) {
+					throw new ECDException("File size significantly exceeds the maximum allowed limit");
+				}
+
 				byte[] excelDataBytes = Base64.decodeBase64(base64File);
 
 				if (excelDataBytes.length > MAX_FILE_SIZE_BYTES)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (excelDataBytes.length > MAX_FILE_SIZE_BYTES)
throw new ECDException("File size exceeds the maximum allowed limit of 5MB");
String base64File = rchFileUploadDto.getFileContent();
// Fast-fail on absurdly large payloads to prevent OOM during decoding.
// A Base64 string's length is roughly 4/3 of the decoded byte array.
if (base64File.length() > MAX_FILE_SIZE_BYTES * 2) {
throw new ECDException("File size significantly exceeds the maximum allowed limit");
}
byte[] excelDataBytes = Base64.decodeBase64(base64File);
if (excelDataBytes.length > MAX_FILE_SIZE_BYTES)
throw new ECDException("File size exceeds the maximum allowed limit of 5MB");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/iemr/ecd/service/data_upload/RCHDataUploadServiceImpl.java`
around lines 85 - 88, Move the size validation in the RCH data upload flow to
the Base64 input before Base64.decodeBase64 executes. Estimate the decoded byte
length from the encoded payload, account for padding as needed, and throw the
existing ECDException when the estimate exceeds MAX_FILE_SIZE_BYTES; retain the
post-decode check only if needed for exact validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants