-
Notifications
You must be signed in to change notification settings - Fork 12
Week not changes but day of call changes caused BUG #881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
… dublicate OBD records in file
WalkthroughThe update modifies the logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant System
participant CsrServiceImpl
participant Subscription
participant CallRetryRecord
System->>CsrServiceImpl: processCallSummaryRecord(callSummaryRecord)
CsrServiceImpl->>Subscription: Get first message day of week
CsrServiceImpl->>CsrServiceImpl: Calculate tomorrow's day of week
CsrServiceImpl->>CsrServiceImpl: Check weekId and day-of-week conditions
alt Condition met
CsrServiceImpl->>CallRetryRecord: Delete retry record if exists
end
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java(2 hunks)
| DayOfTheWeek dayOfTheWeek = subscription.getFirstMessageDayOfWeek(); | ||
| DayOfTheWeek tomorrow = DayOfTheWeek.today().nextDay(); | ||
|
|
||
| //If there was a DOB/LMP update during RCH import, number of weeks into subscription would have changed. | ||
| //No need to reschedule this call. Exception for w1, because regardless of which week the subscription starts in, user | ||
| //always gets w1 message initially | ||
| if(!csrDto.getWeekId().equals("w1_1")&&!weekId.equals(csrDto.getWeekId())){ | ||
| if ((!csrDto.getWeekId().equals("w1_1") && !weekId.equals(csrDto.getWeekId())) || dayOfTheWeek.equals(tomorrow)){ | ||
| if(callRetry!=null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible NullPointerException – guard against a missing firstMessageDayOfWeek value
subscription.getFirstMessageDayOfWeek() can legally be null for older or partially-migrated records.
Dereferencing it in dayOfTheWeek.equals(tomorrow) will crash the whole CSR batch and leave the retry row undeleted, re-introducing the very duplication this PR is fixing.
Diff suggestion:
- DayOfTheWeek dayOfTheWeek = subscription.getFirstMessageDayOfWeek();
- DayOfTheWeek tomorrow = DayOfTheWeek.today().nextDay();
+ DayOfTheWeek firstMessageDay = subscription.getFirstMessageDayOfWeek();
+ DayOfTheWeek tomorrow = DayOfTheWeek.today().nextDay();- if ((!csrDto.getWeekId().equals("w1_1") && !weekId.equals(csrDto.getWeekId())) || dayOfTheWeek.equals(tomorrow)){
+ if ((!csrDto.getWeekId().equals("w1_1") && !weekId.equals(csrDto.getWeekId()))
+ || (firstMessageDay != null && firstMessageDay.equals(tomorrow))) {Without the null-check the nightly job will throw and fail for every record that lacks the field.
📝 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.
| DayOfTheWeek dayOfTheWeek = subscription.getFirstMessageDayOfWeek(); | |
| DayOfTheWeek tomorrow = DayOfTheWeek.today().nextDay(); | |
| //If there was a DOB/LMP update during RCH import, number of weeks into subscription would have changed. | |
| //No need to reschedule this call. Exception for w1, because regardless of which week the subscription starts in, user | |
| //always gets w1 message initially | |
| if(!csrDto.getWeekId().equals("w1_1")&&!weekId.equals(csrDto.getWeekId())){ | |
| if ((!csrDto.getWeekId().equals("w1_1") && !weekId.equals(csrDto.getWeekId())) || dayOfTheWeek.equals(tomorrow)){ | |
| if(callRetry!=null){ | |
| DayOfTheWeek firstMessageDay = subscription.getFirstMessageDayOfWeek(); | |
| DayOfTheWeek tomorrow = DayOfTheWeek.today().nextDay(); | |
| //If there was a DOB/LMP update during RCH import, number of weeks into subscription would have changed. | |
| //No need to reschedule this call. Exception for w1, because regardless of which week the subscription starts in, user | |
| //always gets w1 message initially | |
| if ((!csrDto.getWeekId().equals("w1_1") && !weekId.equals(csrDto.getWeekId())) | |
| || (firstMessageDay != null && firstMessageDay.equals(tomorrow))) { | |
| if(callRetry!=null){ |
🤖 Prompt for AI Agents
In
kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java
around lines 326 to 333, the code dereferences
subscription.getFirstMessageDayOfWeek() without checking for null, which can
cause a NullPointerException for older or partially migrated records. To fix
this, add a null check for dayOfTheWeek before calling
dayOfTheWeek.equals(tomorrow), ensuring the condition only evaluates if
dayOfTheWeek is not null to prevent the batch job from crashing.
… dublicate OBD records in file
Summary by CodeRabbit