Skip to content
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

Deployment #120

Open
wants to merge 114 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
f29735c
adding deployement file to generate jar in github and deploy it on st…
Mandar-Beehyv Jan 7, 2025
5277275
change branch name deployment
Mandar-Beehyv Jan 7, 2025
09cb916
corrected indetation.
Mandar-Beehyv Jan 7, 2025
d9d56d0
ubuntu version change
Mandar-Beehyv Jan 8, 2025
bd7c0eb
added a distributiion
Mandar-Beehyv Jan 8, 2025
d9efaa3
pom file path change
Mandar-Beehyv Jan 8, 2025
4d77864
change staging key ref
Mandar-Beehyv Jan 8, 2025
ec153f4
change key to password
Mandar-Beehyv Jan 8, 2025
0f2c5b1
removed step 4-6
Mandar-Beehyv Jan 8, 2025
7326b28
added artifact
Mandar-Beehyv Jan 8, 2025
bb308e8
change path
Mandar-Beehyv Jan 8, 2025
5427283
adding frontend in yaml
Mandar-Beehyv Jan 8, 2025
3b79635
grunt cli
Mandar-Beehyv Jan 8, 2025
31d106f
conditional statement for grunt cli
Mandar-Beehyv Jan 8, 2025
d48ee3c
npm install
Mandar-Beehyv Jan 8, 2025
e9ed6e3
path change to get files
Mandar-Beehyv Jan 8, 2025
78594da
removed install grunt cli.
Mandar-Beehyv Jan 8, 2025
9b26e6d
change in window location
Mandar-Beehyv Jan 8, 2025
e34d567
adding deployement file to generate jar in github and deploy it on st…
Mandar-Beehyv Jan 7, 2025
b647063
change branch name deployment
Mandar-Beehyv Jan 7, 2025
6b66b0a
corrected indetation.
Mandar-Beehyv Jan 7, 2025
f2ef055
ubuntu version change
Mandar-Beehyv Jan 8, 2025
e5f3c5a
added a distributiion
Mandar-Beehyv Jan 8, 2025
86c4e29
pom file path change
Mandar-Beehyv Jan 8, 2025
3fcec0e
change staging key ref
Mandar-Beehyv Jan 8, 2025
5dcdc4a
change key to password
Mandar-Beehyv Jan 8, 2025
cf2c706
removed step 4-6
Mandar-Beehyv Jan 8, 2025
10bca66
added artifact
Mandar-Beehyv Jan 8, 2025
1270b23
change path
Mandar-Beehyv Jan 8, 2025
8bc098a
adding frontend in yaml
Mandar-Beehyv Jan 8, 2025
05ebbe1
grunt cli
Mandar-Beehyv Jan 8, 2025
41b1943
conditional statement for grunt cli
Mandar-Beehyv Jan 8, 2025
314bcc5
npm install
Mandar-Beehyv Jan 8, 2025
f5d761e
path change to get files
Mandar-Beehyv Jan 8, 2025
8f3f107
removed install grunt cli.
Mandar-Beehyv Jan 8, 2025
1b12722
change in window location
Mandar-Beehyv Jan 8, 2025
0b3d8ab
Merge remote-tracking branch 'origin/deployment' into deployment
Mandar-Beehyv Jan 17, 2025
7b950c2
Update .gitignore
Mandar-Beehyv Jan 17, 2025
92b2916
adding bower_components and node_modules.
Mandar-Beehyv Jan 17, 2025
db2cc64
changed window location in views and urls.js
Mandar-Beehyv Jan 21, 2025
bb5a43f
Changing Kilkari Performance and Mobile Academy Performance
Kantas2601 Jan 21, 2025
3da2781
Changing Course Certificate Template Id and removing OTP message
Kantas2601 Jan 21, 2025
d470262
added mother_subscription_joined and child_subscription_joined in agg…
Mandar-Beehyv Jan 21, 2025
fbc81ed
assami language sms message update
dinesh-beehyv Jan 21, 2025
73aecbb
added fields in check.
Mandar-Beehyv Jan 22, 2025
e29c5ec
added columns in frontend.
Mandar-Beehyv Jan 22, 2025
94b1ae2
Pdf Name
Kantas2601 Jan 22, 2025
a236d92
Merge pull request #121 from motech-implementations/KilkariAndMAPerfo…
Kantas2601 Jan 22, 2025
494d8ca
Corrected indentation and change in with of column of kilkari aggrega…
Mandar-Beehyv Jan 23, 2025
a0e46cf
added mother_subscription_joined and child_subscription_joined in agg…
Mandar-Beehyv Jan 21, 2025
db90bd0
added fields in check.
Mandar-Beehyv Jan 22, 2025
1592207
added columns in frontend.
Mandar-Beehyv Jan 22, 2025
397dfa1
Merge remote-tracking branch 'origin/add-columns-agg-beneficiary-repo…
Mandar-Beehyv Jan 23, 2025
8fd22ec
added mother_subscription_joined and child_subscription_joined in agg…
Mandar-Beehyv Jan 21, 2025
bda402f
added fields in check.
Mandar-Beehyv Jan 22, 2025
376c1a7
added columns in frontend.
Mandar-Beehyv Jan 22, 2025
6a984bb
Corrected indentation and change in with of column of kilkari aggrega…
Mandar-Beehyv Jan 23, 2025
6240c33
Merge remote-tracking branch 'origin/add-columns-agg-beneficiary-repo…
Mandar-Beehyv Jan 23, 2025
6f221d1
rebase with master
Mandar-Beehyv Jan 23, 2025
88cc3dd
rebase with master
Mandar-Beehyv Jan 23, 2025
ab05c2f
rebase with master
Mandar-Beehyv Jan 23, 2025
c29df75
Merge remote-tracking branch 'origin/add-columns-agg-beneficiary-repo…
Mandar-Beehyv Jan 23, 2025
9a424e4
made two new reports kilkari usage mother and kilkari usage children.
Mandar-Beehyv Jan 27, 2025
20a7b61
created kilkari usage child and kilkari usage mother, their dao and t…
Mandar-Beehyv Jan 27, 2025
2b6e848
Added ETL jobs for etl in kilkari usage mother and child report.
Mandar-Beehyv Jan 27, 2025
37f4654
Changed naming conventions in aggregate beneficiary report.
Mandar-Beehyv Jan 27, 2025
316d29a
Merge pull request #123 from motech-implementations/add-columns-agg-b…
Mandar-Beehyv Jan 27, 2025
36ed611
Merge pull request #122 from motech-implementations/add-columns-agg-b…
Mandar-Beehyv Jan 27, 2025
f612f40
made two new reports kilkari usage mother and kilkari usage children.
Mandar-Beehyv Jan 27, 2025
789e548
created kilkari usage child and kilkari usage mother, their dao and t…
Mandar-Beehyv Jan 27, 2025
4c9df24
Added ETL jobs for etl in kilkari usage mother and child report.
Mandar-Beehyv Jan 27, 2025
54c0376
Merge remote-tracking branch 'origin/mother-child-usage-reports' into…
Mandar-Beehyv Jan 28, 2025
fce8a29
added two reports in frontend usage mother and child report and corre…
Mandar-Beehyv Jan 29, 2025
8ccdfdc
Fixed the cell width and table margin and added report name in Kilkar…
Mandar-Beehyv Jan 29, 2025
1b9ff76
Handled location if the location is not present.
Mandar-Beehyv Jan 29, 2025
97b27f4
added comment for recognising method
Mandar-Beehyv Jan 30, 2025
969e3e2
reverting indentation.
Mandar-Beehyv Jan 30, 2025
49eb085
Made code well-structured.
Mandar-Beehyv Jan 31, 2025
3fabc3c
front end error due to unnecessary code resolution.
Mandar-Beehyv Jan 31, 2025
3147890
changed i used in for loop to columnNumber
Mandar-Beehyv Feb 3, 2025
910929e
Merge pull request #124 from motech-implementations/mother-child-usag…
Mandar-Beehyv Feb 3, 2025
560a99d
adding deployement file to generate jar in github and deploy it on st…
Mandar-Beehyv Jan 7, 2025
b69abec
change branch name deployment
Mandar-Beehyv Jan 7, 2025
af6cb80
corrected indetation.
Mandar-Beehyv Jan 7, 2025
db69f51
ubuntu version change
Mandar-Beehyv Jan 8, 2025
2ddfb21
added a distributiion
Mandar-Beehyv Jan 8, 2025
ed83426
pom file path change
Mandar-Beehyv Jan 8, 2025
305d012
change staging key ref
Mandar-Beehyv Jan 8, 2025
d959494
change key to password
Mandar-Beehyv Jan 8, 2025
ce30650
removed step 4-6
Mandar-Beehyv Jan 8, 2025
36187ed
added artifact
Mandar-Beehyv Jan 8, 2025
764d45e
change path
Mandar-Beehyv Jan 8, 2025
8207d5f
adding frontend in yaml
Mandar-Beehyv Jan 8, 2025
b709008
grunt cli
Mandar-Beehyv Jan 8, 2025
e668920
conditional statement for grunt cli
Mandar-Beehyv Jan 8, 2025
2492c09
npm install
Mandar-Beehyv Jan 8, 2025
f4ffa53
path change to get files
Mandar-Beehyv Jan 8, 2025
a3d5e48
removed install grunt cli.
Mandar-Beehyv Jan 8, 2025
cf70122
change in window location
Mandar-Beehyv Jan 8, 2025
7ee92cd
change staging key ref
Mandar-Beehyv Jan 8, 2025
49edd15
change key to password
Mandar-Beehyv Jan 8, 2025
8363acc
removed step 4-6
Mandar-Beehyv Jan 8, 2025
e7eaaa8
added artifact
Mandar-Beehyv Jan 8, 2025
25ba56e
change path
Mandar-Beehyv Jan 8, 2025
4ce4046
adding frontend in yaml
Mandar-Beehyv Jan 8, 2025
07b7302
grunt cli
Mandar-Beehyv Jan 8, 2025
1fdb70d
conditional statement for grunt cli
Mandar-Beehyv Jan 8, 2025
2465528
npm install
Mandar-Beehyv Jan 8, 2025
47cd731
path change to get files
Mandar-Beehyv Jan 8, 2025
d8a6a34
removed install grunt cli.
Mandar-Beehyv Jan 8, 2025
88eb7eb
Update .gitignore
Mandar-Beehyv Jan 17, 2025
3e33d6d
adding bower_components and node_modules.
Mandar-Beehyv Jan 17, 2025
5b725ca
changed window location in views and urls.js
Mandar-Beehyv Jan 21, 2025
a991681
Merge remote-tracking branch 'origin/deployment' into deployment
Mandar-Beehyv Feb 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
45 changes: 45 additions & 0 deletions .github/workflows/NMSReportingSuite-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Deploy to Staging
on:
push:
branches:
- deployment

jobs:
build-and-deploy:
runs-on: ubuntu-20.04
steps:
# Step 1: Check out the code
- name: Checkout repository
uses: actions/checkout@v3
Comment on lines +12 to +13
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update the checkout action to the latest version.

The actions/checkout action version v3 is outdated. Update to the latest version for security and performance improvements.

-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
📝 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
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


# Step 2: Set up Java
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
Comment on lines +16 to +20
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update Java setup and add dependency caching.

The actions/setup-java action version v3 is outdated. Additionally, caching Maven dependencies will improve build times.

       - name: Set up JDK
-        uses: actions/setup-java@v3
+        uses: actions/setup-java@v4
         with:
           java-version: '8'
           distribution: 'temurin'
+          cache: 'maven'
📝 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
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
🧰 Tools
🪛 actionlint (1.7.4)

17-17: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


# Step 3: Build the JAR
- name: Build with Maven
run: mvn clean install -f NMSReportingSuite/pom.xml

# Step 4: Build FrontEnd
- name: Install Frontend Dependencies and Build with Grunt
run: |
cd app
npm install
grunt package

# Step 5: Store deployment data
- uses: actions/upload-artifact@v4
with:
name: my-artifact
path: |
NMSReportingSuite/target/*.war
app/index.html
app/scripts/
app/views/
app/styles/
app/dist/


3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ NMSReportingSuite/NMSReportingSuite.iml
NMSReportingSuite/src/main/resources/app.properties
NMSReportingSuite/target
app/.idea/
app/bower_components/
app/scripts/global/urls.js
app.zip
app/node_modules/
Email/NMSReportingSuite/.idea/
Email/NMSReportingSuite/NMSReportingSuite.iml
Email/NMSReportingSuite/src/main/resources/app.properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public interface AggregateKilkariReportsService {

List<UsageDto> getUsageReport(ReportRequest reportRequest, User currentUser);

List<UsageDto> getMotherUsageReport(ReportRequest reportRequest, User currentUser);

List<UsageDto> getChildUsageReport(ReportRequest reportRequest, User currentUser);

AggregateKilkariReportsDto getKilkariMessageListenershipReport(ReportRequest reportRequest);

AggregateKilkariReportsDto getWhatsAppSubscriberCountReport(ReportRequest reportRequest);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,18 @@ public void createSpecificAggreagateExcel(XSSFWorkbook workbook, AggregateExcelD

spreadsheet.setColumnWidth(0, 4000);

for (int i = 1; i < 15; i++) {
spreadsheet.setColumnWidth(i, 6000);
for (int columnNumber = 1; columnNumber < 15; columnNumber++) {
spreadsheet.setColumnWidth(columnNumber, 6000);
}

XSSFRow row;
int rowid = 8;

if (gridData.getReportName().equalsIgnoreCase("Kilkari Message Matrix") || gridData.getReportName().equalsIgnoreCase("Kilkari Beneficiary Completion")
|| gridData.getReportName().equalsIgnoreCase("Kilkari Usage") || gridData.getReportName().equalsIgnoreCase("Kilkari Call")) {
for (int i = 1; i < 15; i++) {
spreadsheet.setColumnWidth(i, 10000);
|| gridData.getReportName().equalsIgnoreCase("Kilkari Usage") || gridData.getReportName().equalsIgnoreCase("Kilkari Call")
|| gridData.getReportName().equalsIgnoreCase("Kilkari Usage Child") || gridData.getReportName().equalsIgnoreCase("Kilkari Usage Mother")) {
for (int columnNumber = 1; columnNumber < 15; columnNumber++) {
spreadsheet.setColumnWidth(columnNumber, 10000);
}
}

Expand Down Expand Up @@ -707,7 +708,7 @@ public void createSpecificAggreagateExcel(XSSFWorkbook workbook, AggregateExcelD
// gridData.getReportName().equalsIgnoreCase("Kilkari Message Matrix")||
// gridData.getReportName().equalsIgnoreCase("Kilkari Repeat Listener Month Wise")||
// gridData.getReportName().equalsIgnoreCase("Kilkari Cumulative Summary")||
// gridData.getReportName().equalsIgnoreCase("District-wise Performance of the State for Mobile Academy")){
// gridData.getReportName().equalsIgnoreCase("Mobile Academy Performance Report")){
spreadsheet.autoSizeColumn(1);
// }

Expand Down Expand Up @@ -736,7 +737,7 @@ private Map<String,List<String>> getHeaderComment() {
"Number of ASHAs who have successfully completed the course for the first time",
"Number of ASHAs presently Subscribed in the Mobile Academy program but are yet to start or complete the course."
));
map.put("District-wise Performance of the State for Mobile Academy",Arrays.asList("State",
map.put("Mobile Academy Performance Report",Arrays.asList("State",
"Number of ASHAs registered with the program.","Number of ASHA have started the course","% Started (of total registered)",
"number of ASHAs who have passed the course (first successful completion only)",
"% Completed (of total registered)","Number of ASHA have not started the course","% Not Started (of total registered)",
Expand Down Expand Up @@ -971,7 +972,7 @@ public void createSpecificAggreagatePdf(PDDocument document, AggregateExcelDto g
float tableFont = 7;
//contents.close();

if (gridData.getReportName().equalsIgnoreCase("District-wise Performance of the State for Mobile Academy") || gridData.getReportName().equalsIgnoreCase("Kilkari Repeat Listener Month Wise")) {
if (gridData.getReportName().equalsIgnoreCase("Mobile Academy Performance Report") || gridData.getReportName().equalsIgnoreCase("Kilkari Repeat Listener Month Wise")) {
cellWidth = 10f;
tableMargin = 60;
tableFont = 7;
Expand All @@ -996,6 +997,12 @@ public void createSpecificAggreagatePdf(PDDocument document, AggregateExcelDto g
} else if (gridData.getReportName().equalsIgnoreCase("Kilkari Usage")) {
cellWidth = 20f;
tableMargin = 40;
} else if (gridData.getReportName().equalsIgnoreCase("Kilkari Usage Mother")) {
cellWidth = 20f;
tableMargin = 40;
} else if (gridData.getReportName().equalsIgnoreCase("Kilkari Usage Child")) {
cellWidth = 20f;
tableMargin = 40;
} else if (gridData.getReportName().equalsIgnoreCase("Kilkari Call")) {
cellWidth = 10f;
tableMargin = 30;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ public TargetFileNotification generateTargetFile() {
case ASHACERTIFICATE:
productName = "MA Certificate Download through SMS";
messageText = formatCertificateMessage(beneficiary, SMS_CONTENT_ASHACERTIFICATE_PREFIX, languageCode);
String otpMessage = formatCertificateOTPMessage(beneficiary, SMS_CONTENT_ASHACERTIFICATE_OTP_PREFIX, languageCode);
// String otpMessage = formatCertificateOTPMessage(beneficiary, SMS_CONTENT_ASHACERTIFICATE_OTP_PREFIX, languageCode);
templateId = formatTemplateId(languageCode);
writeMessage(writer, msisdn, stateName, productName, templateId, messageText);
writeMessage(writer, msisdn, stateName, productName, SMS_CONTENT_CERTIFICATETemplateId_OTP_PREFIX, otpMessage);
// writeMessage(writer, msisdn, stateName, productName, SMS_CONTENT_CERTIFICATETemplateId_OTP_PREFIX, otpMessage);
flwIds.add(beneficiary.getAshaId());
recordsWritten += 2;
recordsWritten ++;
continue;
Comment on lines 134 to 143
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Verify security implications of removing OTP messages.

The removal of OTP message generation for ASHA certificates could impact the security of the certificate access process. Please verify:

  1. Is this change intentional?
  2. Are there alternative security measures in place?
  3. How will ASHA workers authenticate to access their certificates?

Let's verify if there are any remaining OTP-related functionalities in the codebase:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for OTP-related code and configurations
echo "Searching for OTP-related code..."
rg -i "otp" --type java

echo "Searching for certificate authentication mechanisms..."
rg -i "certificate.*auth" --type java

Length of output: 76011


OTP Security Verification in ASHA Certificate Flow

The OTP mechanism remains intact in the codebase even though the OTP message generation in the AshaTargetFileServiceImpl was removed. Specifically:

  • OTP-related APIs (e.g., generateOTPForAshaCertificate) and validation logic still reside in CertificateServiceImpl and are exposed via dedicated endpoints in UserController (e.g., /asha/generateOTP).
  • ASHA workers are expected to authenticate via these alternative, centralized OTP generation and validation flows.
  • This removal in AshaTargetFileServiceImpl appears intentional, with OTP functionality being handled elsewhere in the system.


default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,20 @@ public Object getReport(@RequestBody ReportRequest reportRequest/*,HttpServletRe
return aggregateResponseDto;
}

if (reportRequest.getReportType().equals(ReportType.usageMother.getReportType())) {
aggregateResponseDto.setBreadCrumbData(breadCrumbs);
List<UsageDto> kilkariMotherUsageDtos = aggregateKilkariReportsService.getMotherUsageReport(reportRequest, currentUser);
aggregateResponseDto.setTableData(kilkariMotherUsageDtos);
return aggregateResponseDto;
}

if (reportRequest.getReportType().equals(ReportType.usageChild.getReportType())) {
aggregateResponseDto.setBreadCrumbData(breadCrumbs);
List<UsageDto> kilkariChildUsageDtos = aggregateKilkariReportsService.getChildUsageReport(reportRequest, currentUser);
aggregateResponseDto.setTableData(kilkariChildUsageDtos);
return aggregateResponseDto;
}

if(reportRequest.getReportType().equals(ReportType.kilkariHomePageReport.getReportType())){
LOGGER.debug("inside this home api");
aggregateResponseDto.setBreadCrumbData(breadCrumbs);
Expand Down Expand Up @@ -1825,6 +1839,20 @@ public String downloadpdf1(HttpServletResponse response, @DefaultValue("") @Quer
"images/drop-down-2.png",
ReportType.usage.getServiceType(),showAggregateReports)
);
kList.add(new Report(
ReportType.usageMother.getReportName(),
ReportType.usageMother.getReportType(),
ReportType.usageMother.getSimpleName(),
"images/drop-down-2.png",
ReportType.usageMother.getServiceType(),showAggregateReports)
);
kList.add(new Report(
ReportType.usageChild.getReportName(),
ReportType.usageChild.getReportType(),
ReportType.usageChild.getSimpleName(),
"images/drop-down-2.png",
ReportType.usageChild.getServiceType(),showAggregateReports)
);
kList.add(new Report(
ReportType.kilkariCalls.getReportName(),
ReportType.kilkariCalls.getReportType(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.beehyv.nmsreporting.dao;

import com.beehyv.nmsreporting.model.KilkariUsageChild;

import java.util.Date;

/**
* Created by beehyv on 27/01/25.
*/
public interface KilkariUsageChildDao {

KilkariUsageChild getUsage(Integer locationId, String locationType, Date toDate, String periodType);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.beehyv.nmsreporting.dao;

import com.beehyv.nmsreporting.model.KilkariUsageMother;

import java.util.Date;

/**
* Created by beehyv on 27/01/25.
*/
public interface KilkariUsageMotherDao {

KilkariUsageMother getUsage(Integer locationId, String locationType, Date toDate, String periodType);

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ public AggregateCumulativeBeneficiary getCumulativeBeneficiary(Long locationId,
List<AggregateCumulativeBeneficiary> result = criteria.list();
if(result.size() < 1){
Long a = (long)0;
AggregateCumulativeBeneficiary aggregateCumulativeBeneficiary = new AggregateCumulativeBeneficiary(0,locationType,locationId,toDate,a,a,a,a,a,a,a,"",a);
AggregateCumulativeBeneficiary aggregateCumulativeBeneficiary = new AggregateCumulativeBeneficiary(0,locationType,locationId,toDate,a,a,a,a,a,a,a,a,a,"",a);
return aggregateCumulativeBeneficiary;
}
AggregateCumulativeBeneficiary aggregateCumulativeBeneficiary = result.get(0);
aggregateCumulativeBeneficiary.setJoinedSubscription(aggregateCumulativeBeneficiary.getJoinedSubscription() == null ? 0 : aggregateCumulativeBeneficiary.getJoinedSubscription());
aggregateCumulativeBeneficiary.setChildSubscriptionJoined(aggregateCumulativeBeneficiary.getChildSubscriptionJoined() == null ? 0 : aggregateCumulativeBeneficiary.getChildSubscriptionJoined());
aggregateCumulativeBeneficiary.setMotherSubscriptionJoined(aggregateCumulativeBeneficiary.getMotherSubscriptionJoined() == null ? 0 : aggregateCumulativeBeneficiary.getMotherSubscriptionJoined());
aggregateCumulativeBeneficiary.setChildCompletion(aggregateCumulativeBeneficiary.getChildCompletion() == null ? 0 : aggregateCumulativeBeneficiary.getChildCompletion());
aggregateCumulativeBeneficiary.setMotherCompletion(aggregateCumulativeBeneficiary.getMotherCompletion() == null ? 0 : aggregateCumulativeBeneficiary.getMotherCompletion());
aggregateCumulativeBeneficiary.setLowListenership(aggregateCumulativeBeneficiary.getLowListenership() == null ? 0 : aggregateCumulativeBeneficiary.getLowListenership());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.beehyv.nmsreporting.dao.impl;

import com.beehyv.nmsreporting.dao.AbstractDao;
import com.beehyv.nmsreporting.dao.KilkariUsageChildDao;

import com.beehyv.nmsreporting.model.KilkariUsageChild;
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
* Created by beehyv on 27/02/25.
*/
@Repository("usageChildDao")
public class KilkariUsageChildDaoImpl extends AbstractDao<Integer, KilkariUsageChild> implements KilkariUsageChildDao {

@Override
public KilkariUsageChild getUsage(Integer locationId, String locationType, Date toDate, String periodType){

Criteria criteria = createEntityCriteria().addOrder(Order.asc("locationId"));
criteria.add(Restrictions.and(
Restrictions.eq("locationId",locationId.longValue()),
Restrictions.eq("locationType",locationType),
Restrictions.eq("periodType",periodType),
Restrictions.eq("date",toDate)
));
List<KilkariUsageChild> result = criteria.list();
if(result.isEmpty()){
Long a = (long)0;
KilkariUsageChild kilkariUsageChild = new KilkariUsageChild(0,locationType,locationId.longValue(),toDate,a,a,a,a,a,a,a,"");
return kilkariUsageChild;
}
KilkariUsageChild kilkariUsageChild = result.get(0);
kilkariUsageChild.setCalls_1_25(kilkariUsageChild.getCalls_1_25() == null ? 0 : kilkariUsageChild.getCalls_1_25());
kilkariUsageChild.setCalls_25_50(kilkariUsageChild.getCalls_25_50() == null ? 0 : kilkariUsageChild.getCalls_25_50());
kilkariUsageChild.setCalls_50_75(kilkariUsageChild.getCalls_50_75() == null ? 0 : kilkariUsageChild.getCalls_50_75());
kilkariUsageChild.setCalls_75_100(kilkariUsageChild.getCalls_75_100() == null ? 0 : kilkariUsageChild.getCalls_75_100());
kilkariUsageChild.setCalledInbox(kilkariUsageChild.getCalledInbox() == null ? 0 : kilkariUsageChild.getCalledInbox());
kilkariUsageChild.setAnsweredAtleastOneCall(kilkariUsageChild.getAnsweredAtleastOneCall() == null ? 0 : kilkariUsageChild.getAnsweredAtleastOneCall());
kilkariUsageChild.setTotalBeneficiariesCalled(kilkariUsageChild.getTotalBeneficiariesCalled() == null ? 0 : kilkariUsageChild.getTotalBeneficiariesCalled());
Comment on lines +38 to +44
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor null checks using a utility method.

Multiple similar null checks can be simplified using a utility method.

+    private Long getValueOrDefault(Long value) {
+        return value == null ? 0L : value;
+    }
 
-    kilkariUsageChild.setCalls_1_25(kilkariUsageChild.getCalls_1_25() == null ? 0 : kilkariUsageChild.getCalls_1_25());
-    kilkariUsageChild.setCalls_25_50(kilkariUsageChild.getCalls_25_50() == null ? 0 : kilkariUsageChild.getCalls_25_50());
-    kilkariUsageChild.setCalls_50_75(kilkariUsageChild.getCalls_50_75() == null ? 0 : kilkariUsageChild.getCalls_50_75());
-    kilkariUsageChild.setCalls_75_100(kilkariUsageChild.getCalls_75_100() == null ? 0 : kilkariUsageChild.getCalls_75_100());
-    kilkariUsageChild.setCalledInbox(kilkariUsageChild.getCalledInbox() == null ? 0 : kilkariUsageChild.getCalledInbox());
-    kilkariUsageChild.setAnsweredAtleastOneCall(kilkariUsageChild.getAnsweredAtleastOneCall() == null ? 0 : kilkariUsageChild.getAnsweredAtleastOneCall());
-    kilkariUsageChild.setTotalBeneficiariesCalled(kilkariUsageChild.getTotalBeneficiariesCalled() == null ? 0 : kilkariUsageChild.getTotalBeneficiariesCalled());
+    kilkariUsageChild.setCalls_1_25(getValueOrDefault(kilkariUsageChild.getCalls_1_25()));
+    kilkariUsageChild.setCalls_25_50(getValueOrDefault(kilkariUsageChild.getCalls_25_50()));
+    kilkariUsageChild.setCalls_50_75(getValueOrDefault(kilkariUsageChild.getCalls_50_75()));
+    kilkariUsageChild.setCalls_75_100(getValueOrDefault(kilkariUsageChild.getCalls_75_100()));
+    kilkariUsageChild.setCalledInbox(getValueOrDefault(kilkariUsageChild.getCalledInbox()));
+    kilkariUsageChild.setAnsweredAtleastOneCall(getValueOrDefault(kilkariUsageChild.getAnsweredAtleastOneCall()));
+    kilkariUsageChild.setTotalBeneficiariesCalled(getValueOrDefault(kilkariUsageChild.getTotalBeneficiariesCalled()));
📝 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
kilkariUsageChild.setCalls_1_25(kilkariUsageChild.getCalls_1_25() == null ? 0 : kilkariUsageChild.getCalls_1_25());
kilkariUsageChild.setCalls_25_50(kilkariUsageChild.getCalls_25_50() == null ? 0 : kilkariUsageChild.getCalls_25_50());
kilkariUsageChild.setCalls_50_75(kilkariUsageChild.getCalls_50_75() == null ? 0 : kilkariUsageChild.getCalls_50_75());
kilkariUsageChild.setCalls_75_100(kilkariUsageChild.getCalls_75_100() == null ? 0 : kilkariUsageChild.getCalls_75_100());
kilkariUsageChild.setCalledInbox(kilkariUsageChild.getCalledInbox() == null ? 0 : kilkariUsageChild.getCalledInbox());
kilkariUsageChild.setAnsweredAtleastOneCall(kilkariUsageChild.getAnsweredAtleastOneCall() == null ? 0 : kilkariUsageChild.getAnsweredAtleastOneCall());
kilkariUsageChild.setTotalBeneficiariesCalled(kilkariUsageChild.getTotalBeneficiariesCalled() == null ? 0 : kilkariUsageChild.getTotalBeneficiariesCalled());
private Long getValueOrDefault(Long value) {
return value == null ? 0L : value;
}
kilkariUsageChild.setCalls_1_25(getValueOrDefault(kilkariUsageChild.getCalls_1_25()));
kilkariUsageChild.setCalls_25_50(getValueOrDefault(kilkariUsageChild.getCalls_25_50()));
kilkariUsageChild.setCalls_50_75(getValueOrDefault(kilkariUsageChild.getCalls_50_75()));
kilkariUsageChild.setCalls_75_100(getValueOrDefault(kilkariUsageChild.getCalls_75_100()));
kilkariUsageChild.setCalledInbox(getValueOrDefault(kilkariUsageChild.getCalledInbox()));
kilkariUsageChild.setAnsweredAtleastOneCall(getValueOrDefault(kilkariUsageChild.getAnsweredAtleastOneCall()));
kilkariUsageChild.setTotalBeneficiariesCalled(getValueOrDefault(kilkariUsageChild.getTotalBeneficiariesCalled()));

return kilkariUsageChild;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.beehyv.nmsreporting.dao.impl;

import com.beehyv.nmsreporting.dao.AbstractDao;
import com.beehyv.nmsreporting.dao.KilkariUsageMotherDao;
import com.beehyv.nmsreporting.model.KilkariUsageMother;
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
* Created by beehyv on 27/02/25.
*/
@Repository("usageMotherDao")
public class KilkariUsageMotherDaoImpl extends AbstractDao<Integer, KilkariUsageMother> implements KilkariUsageMotherDao {

@Override
public KilkariUsageMother getUsage(Integer locationId, String locationType, Date toDate, String periodType){

Criteria criteria = createEntityCriteria().addOrder(Order.asc("locationId"));
criteria.add(Restrictions.and(
Restrictions.eq("locationId",locationId.longValue()),
Restrictions.eq("locationType",locationType),
Restrictions.eq("periodType",periodType),
Restrictions.eq("date",toDate)
));
List<KilkariUsageMother> result = criteria.list();
if(result.isEmpty()){
Long a = (long)0;
KilkariUsageMother kilkariUsageMother = new KilkariUsageMother(0,locationType,locationId.longValue(),toDate,a,a,a,a,a,a,a,"");
return kilkariUsageMother;
}
KilkariUsageMother kilkariUsageMother = result.get(0);
kilkariUsageMother.setCalls_1_25(kilkariUsageMother.getCalls_1_25() == null ? 0 : kilkariUsageMother.getCalls_1_25());
kilkariUsageMother.setCalls_25_50(kilkariUsageMother.getCalls_25_50() == null ? 0 : kilkariUsageMother.getCalls_25_50());
kilkariUsageMother.setCalls_50_75(kilkariUsageMother.getCalls_50_75() == null ? 0 : kilkariUsageMother.getCalls_50_75());
kilkariUsageMother.setCalls_75_100(kilkariUsageMother.getCalls_75_100() == null ? 0 : kilkariUsageMother.getCalls_75_100());
kilkariUsageMother.setCalledInbox(kilkariUsageMother.getCalledInbox() == null ? 0 : kilkariUsageMother.getCalledInbox());
kilkariUsageMother.setAnsweredAtleastOneCall(kilkariUsageMother.getAnsweredAtleastOneCall() == null ? 0 : kilkariUsageMother.getAnsweredAtleastOneCall());
kilkariUsageMother.setTotalBeneficiariesCalled(kilkariUsageMother.getTotalBeneficiariesCalled() == null ? 0 : kilkariUsageMother.getTotalBeneficiariesCalled());
return kilkariUsageMother;
}
Comment on lines +18 to +45
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider creating a common base class for usage DAOs.

The implementation is almost identical to KilkariUsageChildDaoImpl. Consider creating a common base class to reduce code duplication.

+public abstract class AbstractKilkariUsageDao<T> extends AbstractDao<Integer, T> {
+    protected T getUsageInternal(Integer locationId, String locationType, Date toDate, String periodType, 
+                                Function<Long, T> constructor) {
+        Criteria criteria = createEntityCriteria().addOrder(Order.asc("locationId"));
+        criteria.add(Restrictions.and(
+            Restrictions.eq("locationId", locationId.longValue()),
+            Restrictions.eq("locationType", locationType),
+            Restrictions.eq("periodType", periodType),
+            Restrictions.eq("date", toDate)
+        ));
+        List<T> result = criteria.list();
+        if (result.isEmpty()) {
+            return constructor.apply(0L);
+        }
+        return initializeNullFields(result.get(0));
+    }
+
+    protected abstract T initializeNullFields(T entity);
+}
+
+@Repository("usageMotherDao")
+public class KilkariUsageMotherDaoImpl extends AbstractKilkariUsageDao<KilkariUsageMother> 
+    implements KilkariUsageMotherDao {
+    
+    @Override
+    public KilkariUsageMother getUsage(Integer locationId, String locationType, Date toDate, String periodType) {
+        return getUsageInternal(locationId, locationType, toDate, periodType,
+            defaultValue -> new KilkariUsageMother(0, locationType, locationId.longValue(), toDate,
+                defaultValue, defaultValue, defaultValue, defaultValue, defaultValue, defaultValue, defaultValue, ""));
+    }
+
+    @Override
+    protected KilkariUsageMother initializeNullFields(KilkariUsageMother entity) {
+        entity.setCalls_1_25(getValueOrDefault(entity.getCalls_1_25()));
+        // ... similar for other fields
+        return entity;
+    }
+}

Committable suggestion skipped: line range outside the PR's diff.


}
Comment on lines +1 to +47
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Extract common functionality to a base class.

This implementation is nearly identical to KilkariUsageChildDaoImpl. Consider creating a common base class to reduce code duplication.

Example refactor:

@MappedSuperclass
public abstract class AbstractKilkariUsageDao<T> extends AbstractDao<Integer, T> {
    protected static final long DEFAULT_COUNT = 0L;
    protected static final int DEFAULT_ID = 0;

    protected T getUsageInternal(Integer locationId, String locationType, 
                               Date toDate, String periodType,
                               Function<Object[], T> constructor) {
        Criteria criteria = createEntityCriteria()
            .addOrder(Order.asc("locationId"))
            .add(Restrictions.and(
                Restrictions.eq("locationId", locationId.longValue()),
                Restrictions.eq("locationType", locationType),
                Restrictions.eq("periodType", periodType),
                Restrictions.eq("date", toDate)
            ));
            
        return Optional.ofNullable(criteria.uniqueResult())
            .map(result -> {
                T usage = (T) result;
                initializeNullMetrics(usage);
                return usage;
            })
            .orElseGet(() -> createDefaultUsage(locationId, locationType, 
                                               toDate, constructor));
    }

    protected abstract void initializeNullMetrics(T usage);
    protected abstract T createDefaultUsage(Integer locationId, 
        String locationType, Date toDate, Function<Object[], T> constructor);
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class KilkariAggregateBeneficiariesDto {
private Long childCompletion;
private Long calledInbox;
private Long joinedSubscription;
private Long motherSubscriptionJoined;
private Long childSubscriptionJoined;
private boolean link = false;

public Integer getId() {
Expand Down Expand Up @@ -133,6 +135,22 @@ public void setJoinedSubscription(Long joinedSubscription) {
this.joinedSubscription = joinedSubscription;
}

public Long getChildSubscriptionJoined() {
return childSubscriptionJoined;
}

public void setChildSubscriptionJoined(Long childSubscriptionJoined) {
this.childSubscriptionJoined = childSubscriptionJoined;
}

public Long getMotherSubscriptionJoined() {
return motherSubscriptionJoined;
}

public void setMotherSubscriptionJoined(Long motherSubscriptionJoined) {
this.motherSubscriptionJoined = motherSubscriptionJoined;
}

public boolean isLink() {
return link;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public enum EtlJobForNotifications {
Kilkari_Usage_Report_Quarter(" KilkariUsageReportQuarter", "Kilkari Usage","QUARTERLY", "REPORTS"),
Kilkari_Usage_Report_Year(" KilkariUsageReportYear", "Kilkari Usage","YEARLY", "REPORTS"),
Kilkari_Usage_Report_FinancialYear(" KilkariUsageReportFinancialYear", "Kilkari Usage","FINANCIALYEAR", "REPORTS"),
Kilkari_Usage_Mother_Report_Monthly(" KilkariUsageMotherReportMonthly", "Kilkari Usage Mother","MONTHLY", "REPORTS"),
Kilkari_Usage_Mother_Report_Quarter(" KilkariUsageMotherReportQuarter", "Kilkari Usage Mother","QUARTERLY", "REPORTS"),
Kilkari_Usage_Mother_Report_Year(" KilkariUsageMotherReportYear", "Kilkari Usage Mother","YEARLY", "REPORTS"),
Kilkari_Usage_Mother_Report_FinancialYear(" KilkariUsageMotherReportFinancialYear", "Kilkari Usage Mother","FINANCIALYEAR", "REPORTS"),
Kilkari_Usage_Child_Report_Monthly(" KilkariUsageChildReportMonthly", "Kilkari Usage Child","MONTHLY", "REPORTS"),
Kilkari_Usage_Child_Report_Quarter(" KilkariUsageChildReportQuarter", "Kilkari Usage Child","QUARTERLY", "REPORTS"),
Kilkari_Usage_Child_Report_Year(" KilkariUsageChildReportYear", "Kilkari Usage Child","YEARLY", "REPORTS"),
Kilkari_Usage_Child_Report_FinancialYear(" KilkariUsageChildReportFinancialYear", "Kilkari Usage Child","FINANCIALYEAR", "REPORTS"),
Kilkari_Thematic_Content_Monthly(" KilkariThematicContentMonthly", "Kilkari Thematic Content","MONTHLY", "REPORTS"),
Kilkari_Thematic_Content_Quarter(" KilkariThematicContentQuarter", "Kilkari Thematic Content","QUARTERLY", "REPORTS"),
Kilkari_Thematic_Content_Year(" KilkariThematicContentYear", "Kilkari Thematic Content","YEARLY", "REPORTS"),
Expand Down
Loading