Aman-Mittal commented on code in PR #5410:
URL: https://github.com/apache/fineract/pull/5410#discussion_r2747231692
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java:
##########
@@ -601,6 +602,29 @@ public Long retrieveClientIdByExternalId(final ExternalId
externalId) {
return clientRepositoryWrapper.findIdByExternalId(externalId);
}
+ @Override
+ public ClientPerformanceData retrieveClientPerformance(final Long
clientId) {
+ try {
+ final String checkClientSql = "SELECT count(*) FROM m_client WHERE
id = ?";
+ final Integer count =
this.jdbcTemplate.queryForObject(checkClientSql, Integer.class, clientId);
+ if (count == null || count == 0) {
+ throw new ClientNotFoundException(clientId);
+ }
+ final String sql = "SELECT " + "(SELECT COUNT(*) FROM m_loan WHERE
client_id = c.id AND loan_status_id = 300) as activeLoans, "
+ + "(SELECT COALESCE(SUM(principal_outstanding_derived +
interest_outstanding_derived + fee_charges_outstanding_derived +
penalty_charges_outstanding_derived), 0) "
+ + " FROM m_loan WHERE client_id = c.id AND loan_status_id
= 300) as totalOutstanding "
+ + "FROM m_client c WHERE c.id = ?";
Review Comment:
StringBuilder will help if the sql written here was dynamic but i can see
there is a simple static string. In that case there is no performance gain
using this. This will make it harder to review lateron
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]