|
33 | 33 | import static org.hisp.dhis.analytics.table.ColumnRegex.NUMERIC_REGEXP; |
34 | 34 | import static org.hisp.dhis.analytics.table.model.AnalyticsValueType.FACT; |
35 | 35 | import static org.hisp.dhis.analytics.table.util.PartitionUtils.getLatestTablePartition; |
| 36 | +import static org.hisp.dhis.commons.util.TextUtils.SPACE; |
36 | 37 | import static org.hisp.dhis.commons.util.TextUtils.emptyIfTrue; |
37 | 38 | import static org.hisp.dhis.commons.util.TextUtils.format; |
38 | 39 | import static org.hisp.dhis.commons.util.TextUtils.replace; |
@@ -413,20 +414,29 @@ where des.valuetype in (${valTypes}) \ |
413 | 414 | "startTime", toLongDate(params.getStartTime()), |
414 | 415 | "deletedClause", sqlBuilder.isFalse("dv", "deleted")))); |
415 | 416 |
|
| 417 | + sql.append(getStartEndDatesCondition(respectStartEndDates)); |
| 418 | + |
| 419 | + if (whereClause != null) { |
| 420 | + sql.append(" and " + whereClause + " "); |
| 421 | + } |
| 422 | + |
| 423 | + invokeTimeAndLog(sql.toString(), "Populating table: '{}' {}", tableName, valueTypes); |
| 424 | + } |
| 425 | + |
| 426 | + String getStartEndDatesCondition(boolean respectStartEndDates) { |
| 427 | + StringBuilder condition = new StringBuilder(""); |
| 428 | + |
416 | 429 | if (respectStartEndDates) { |
417 | | - sql.append( |
| 430 | + condition.append(SPACE); |
| 431 | + condition.append( |
418 | 432 | """ |
419 | 433 | and (aon.startdate is null or aon.startdate <= ps.startdate) \ |
420 | 434 | and (aon.enddate is null or aon.enddate >= ps.enddate) \ |
421 | 435 | and (con.startdate is null or con.startdate <= ps.startdate) \ |
422 | 436 | and (con.enddate is null or con.enddate >= ps.enddate)\s"""); |
423 | 437 | } |
424 | 438 |
|
425 | | - if (whereClause != null) { |
426 | | - sql.append(" and " + whereClause + " "); |
427 | | - } |
428 | | - |
429 | | - invokeTimeAndLog(sql.toString(), "Populating table: '{}' {}", tableName, valueTypes); |
| 439 | + return condition.toString(); |
430 | 440 | } |
431 | 441 |
|
432 | 442 | /** |
|
0 commit comments