Skip to content

Commit

Permalink
Code Rabbit Fixes removed unwanted code
Browse files Browse the repository at this point in the history
  • Loading branch information
sushantpatil1214 committed Oct 22, 2024
1 parent 0d28367 commit 74b9909
Showing 1 changed file with 2 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private Behavior<Event> getFieldCountHandler(final GetFieldCountRequest request)
request.replyTo.tell(new GetFieldCountResponse(getCount));
} catch (Exception e) {
LOGGER.error(e.getLocalizedMessage(), e);
LOGGER.error("libMPI.getFieldCount failed for goldenId: {} with error: {}", e.getMessage());
LOGGER.error("libMPI.getFieldCount failed for with error: {}", e.getMessage());
}
return Behaviors.same();
}
Expand All @@ -543,7 +543,7 @@ private Behavior<Event> getAgeGroupCountHandler(final GetAgeGroupCountRequest re
request.replyTo.tell(new GetAgeGroupCountResponse(getCount));
} catch (Exception e) {
LOGGER.error(e.getLocalizedMessage(), e);
LOGGER.error("libMPI.getAgeGroupCountHandler failed for goldenId: {} with error: {}", e.getMessage());
LOGGER.error("libMPI.getAgeGroupCountHandler failed with error: {}", e.getMessage());
}
return Behaviors.same();
}
Expand All @@ -553,7 +553,6 @@ private Behavior<Event> getAllListHandler(final GetAllListRequest request) {
try {
dobList = libMPI.getAllList(request.allListRequest);
LOGGER.info("dobList size: {}", dobList.size());
// double allList = calculateAvarageAge(dobList);
request.replyTo.tell(new GetAllListResponse(dobList));
} catch (Exception e) {
LOGGER.error(e.getLocalizedMessage(), e);
Expand All @@ -562,28 +561,6 @@ private Behavior<Event> getAllListHandler(final GetAllListRequest request) {
return Behaviors.same();
}

public static double calculateAvarageAge(final List<String> dobList) {
LocalDate today = LocalDate.now(); // Get today's date
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); // DOB format in YYYYMMDD
int totalAge = 0;
int count = 0;
// Iterate through the list of DOBs and calculate the age for each
for (String dob : dobList) {
if (dob != null && !dob.isEmpty()) {
try {
LocalDate birthDate = LocalDate.parse(dob, formatter); // Try to convert DOB to LocalDate
int age = Period.between(birthDate, today).getYears(); // Calculate age in years
totalAge += age;
count++;
} catch (DateTimeParseException e) {
LOGGER.error("Invalid date format for dob: {}. Skipping this record.", dob);
}
}
}
// Calculate and return average age
return count > 0 ? (double) totalAge / count : 0;
}

private Behavior<Event> getFieldsConfigurationHandler(final GetFieldsConfigurationRequest request) {
final var separator = FileSystems.getDefault().getSeparator();
final String configDir = System.getenv("SYSTEM_CONFIG_DIRS");
Expand Down

0 comments on commit 74b9909

Please sign in to comment.