Uploaded image for project: 'Apache Fineract'
  1. Apache Fineract
  2. FINERACT-1937

Is catch up COB running query is faulty

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.9.0
    • None

    Description

      {{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));}}

      Attachments

        Issue Links

          Activity

            People

              taskain Norbert Táskai
              taskain7 Norbert Táskai
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: