You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by "Norbert Táskai (Jira)" <ji...@apache.org> on 2023/06/08 05:29:00 UTC

[jira] [Created] (FINERACT-1937) Is catch up COB running query is faulty

Norbert Táskai created FINERACT-1937:
----------------------------------------

             Summary: Is catch up COB running query is faulty
                 Key: FINERACT-1937
                 URL: https://issues.apache.org/jira/browse/FINERACT-1937
             Project: Apache Fineract
          Issue Type: Bug
            Reporter: Norbert Táskai


{{public List<Long> getRunningJobsIdsByExecutionParameter(String jobName, String jobCustomParamKeyName, String parameterKeyName,            String parameterValue) \{
        final StringBuilder sqlStatementBuilder = new StringBuilder();
        String jsonString = gson.toJson(new JobParameterDTO(parameterKeyName, parameterValue));
        sqlStatementBuilder.append(
                "SELECT bje.JOB_EXECUTION_ID FROM BATCH_JOB_INSTANCE bji INNER JOIN BATCH_JOB_EXECUTION bje ON bji.JOB_INSTANCE_ID = bje.JOB_INSTANCE_ID INNER JOIN BATCH_JOB_EXECUTION_PARAMS bjep ON bje.JOB_EXECUTION_ID = bjep.JOB_EXECUTION_ID"
                        + " WHERE bje.STATUS IN (:statuses) AND bji.JOB_NAME = :jobName AND bjep.KEY_NAME = :jobCustomParamKeyName AND bjep.LONG_VAL IN ("
                        + getSubQueryForCustomJobParameters()
                        + ") AND bje.JOB_INSTANCE_ID NOT IN (SELECT bje.JOB_INSTANCE_ID FROM BATCH_JOB_INSTANCE bji INNER JOIN BATCH_JOB_EXECUTION bje ON bji.JOB_INSTANCE_ID = bje.JOB_INSTANCE_ID"
                        + " WHERE bje.STATUS = :completedStatus AND bji.JOB_NAME = :jobName)");
        return namedParameterJdbcTemplate.queryForList(
                sqlStatementBuilder.toString(), Map.of("statuses", List.of(STARTED.name(), STARTING.name()), "jobName", jobName,
                        "completedStatus", COMPLETED.name(), "jobCustomParamKeyName", jobCustomParamKeyName, "jsonString", jsonString),
                Long.class);
    }}}
 

Below should be updated to not use the job explorer to fetch the business date rather the query should be used.
 {{ List<Long> runningCatchUpExecutionIds = jobExecutionRepository.getRunningJobsIdsByExecutionParameter(LoanCOBConstant.JOB_NAME,                LoanCOBConstant.LOAN_COB_CUSTOM_JOB_PARAMETER_KEY, LoanCOBConstant.IS_CATCH_UP_PARAMETER_NAME, "true");
        return runningCatchUpExecutionIds //
                .stream() //
                .findFirst() //
                .map(jobExplorer::getJobExecution) //
                .map(JobExecution::getExecutionContext) //
                .map(executionContext -> executionContext.getString(LoanCOBConstant.BUSINESS_DATE_PARAMETER_NAME)) //
                .map(result -> new IsCatchUpRunningDTO(true, LocalDate.parse(result, DateTimeFormatter.ISO_DATE))) //
                .orElse(new IsCatchUpRunningDTO(false, null));}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)