TSK-1614: sql now working without db2 compatibility vector

This commit is contained in:
Mustapha Zorgati 2021-04-08 12:45:26 +02:00
parent 1fe5aa7e72
commit 3fb55790ec
1 changed files with 8 additions and 8 deletions

View File

@ -24,7 +24,7 @@ public interface MonitorMapper {
@Select(
"<script>"
+ "SELECT B.WORKBASKET_KEY, B.AGE_IN_DAYS, COUNT(B.AGE_IN_DAYS) AS NUMBER_OF_TASKS FROM ("
+ "<if test=\"_databaseId == 'db2'\">SELECT T.WORKBASKET_KEY, (DAYS(T.${timestamp}) - DAYS(#{now})) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'db2'\">SELECT T.WORKBASKET_KEY, (DAYS(T.${timestamp}) - DAYS(CAST(#{now} as TIMESTAMP))) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'h2'\">SELECT T.WORKBASKET_KEY, DATEDIFF('DAY', #{now}, T.${timestamp}) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'postgres'\">SELECT T.WORKBASKET_KEY, DATE_PART('DAY', T.${timestamp} - #{now}) as AGE_IN_DAYS </if> "
+ "FROM TASK AS T LEFT JOIN ATTACHMENT AS A ON T.ID = A.TASK_ID "
@ -82,7 +82,7 @@ public interface MonitorMapper {
@Select(
"<script>"
+ "SELECT B.CLASSIFICATION_CATEGORY, B.AGE_IN_DAYS, COUNT(B.AGE_IN_DAYS) AS NUMBER_OF_TASKS FROM ("
+ "<if test=\"_databaseId == 'db2'\">SELECT CLASSIFICATION_CATEGORY, (DAYS(${timestamp}) - DAYS(#{now})) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'db2'\">SELECT CLASSIFICATION_CATEGORY, (DAYS(${timestamp}) - DAYS(CAST(#{now} as TIMESTAMP))) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'h2'\">SELECT CLASSIFICATION_CATEGORY, DATEDIFF('DAY', #{now}, ${timestamp}) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'postgres'\">SELECT CLASSIFICATION_CATEGORY, DATE_PART('DAY', ${timestamp} - #{now}) as AGE_IN_DAYS </if> "
+ "FROM TASK "
@ -130,7 +130,7 @@ public interface MonitorMapper {
@Select(
"<script>"
+ "SELECT B.CLASSIFICATION_KEY, B.AGE_IN_DAYS, COUNT(B.AGE_IN_DAYS) AS NUMBER_OF_TASKS FROM ("
+ "<if test=\"_databaseId == 'db2'\">SELECT CLASSIFICATION_KEY, (DAYS(${timestamp}) - DAYS(#{now})) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'db2'\">SELECT CLASSIFICATION_KEY, (DAYS(${timestamp}) - DAYS(CAST(#{now} as TIMESTAMP))) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'h2'\">SELECT CLASSIFICATION_KEY, DATEDIFF('DAY', #{now}, ${timestamp}) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'postgres'\">SELECT CLASSIFICATION_KEY, DATE_PART('DAY', ${timestamp} - #{now}) as AGE_IN_DAYS </if> "
+ "FROM TASK "
@ -178,7 +178,7 @@ public interface MonitorMapper {
@Select(
"<script>"
+ "SELECT B.TASK_CLASSIFICATION_KEY, B.ATTACHMENT_CLASSIFICATION_KEY, B.AGE_IN_DAYS, COUNT(B.AGE_IN_DAYS) AS NUMBER_OF_TASKS FROM ("
+ "<if test=\"_databaseId == 'db2'\">SELECT T.CLASSIFICATION_KEY as TASK_CLASSIFICATION_KEY, A.CLASSIFICATION_KEY as ATTACHMENT_CLASSIFICATION_KEY, (DAYS(T.${timestamp}) - DAYS(#{now})) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'db2'\">SELECT T.CLASSIFICATION_KEY as TASK_CLASSIFICATION_KEY, A.CLASSIFICATION_KEY as ATTACHMENT_CLASSIFICATION_KEY, (DAYS(T.${timestamp}) - DAYS(CAST(#{now} as TIMESTAMP))) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'h2'\">SELECT T.CLASSIFICATION_KEY as TASK_CLASSIFICATION_KEY, A.CLASSIFICATION_KEY as ATTACHMENT_CLASSIFICATION_KEY, DATEDIFF('DAY', #{now}, T.${timestamp}) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'postgres'\">SELECT T.CLASSIFICATION_KEY as TASK_CLASSIFICATION_KEY, A.CLASSIFICATION_KEY as ATTACHMENT_CLASSIFICATION_KEY, DATE_PART('DAY', T.${timestamp} - #{now}) as AGE_IN_DAYS </if> "
+ "FROM TASK AS T LEFT JOIN ATTACHMENT AS A ON T.ID = A.TASK_ID "
@ -227,7 +227,7 @@ public interface MonitorMapper {
@Select(
"<script>"
+ "SELECT B.CUSTOM_FIELD, B.AGE_IN_DAYS, COUNT(B.AGE_IN_DAYS) AS NUMBER_OF_TASKS FROM ("
+ "<if test=\"_databaseId == 'db2'\">SELECT ${customField} as CUSTOM_FIELD, (DAYS(${timestamp}) - DAYS(#{now})) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'db2'\">SELECT ${customField} as CUSTOM_FIELD, (DAYS(${timestamp}) - DAYS(CAST(#{now} as TIMESTAMP))) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'h2'\">SELECT ${customField} as CUSTOM_FIELD, DATEDIFF('DAY', #{now}, ${timestamp}) as AGE_IN_DAYS </if> "
+ "<if test=\"_databaseId == 'postgres'\">SELECT ${customField} as CUSTOM_FIELD, DATE_PART('DAY', ${timestamp} - #{now}) as AGE_IN_DAYS </if> "
+ "FROM TASK "
@ -318,8 +318,8 @@ public interface MonitorMapper {
+ "</if>"
+ "</if>"
+ "<if test=\"_databaseId == 'db2'\">"
+ "#{selectedItem.upperAgeLimit} >= (DAYS(${timestamp}) - DAYS(#{now})) AND "
+ "#{selectedItem.lowerAgeLimit} &lt;= (DAYS(${timestamp}) - DAYS(#{now})) "
+ "#{selectedItem.upperAgeLimit} >= (DAYS(${timestamp}) - DAYS(CAST(#{now} as TIMESTAMP))) AND "
+ "#{selectedItem.lowerAgeLimit} &lt;= (DAYS(${timestamp}) - DAYS(CAST(#{now} as TIMESTAMP))) "
+ "</if> "
+ "<if test=\"_databaseId == 'h2'\">"
+ "#{selectedItem.upperAgeLimit} >= DATEDIFF('DAY', #{now}, ${timestamp}) AND "
@ -440,7 +440,7 @@ public interface MonitorMapper {
// overhead / complexity. It's worth the trade-off of not computing the AGE_IN_DAYS column
// twice.
+ "SELECT W.ORG_LEVEL_1, W.ORG_LEVEL_2, W.ORG_LEVEL_3, W.ORG_LEVEL_4, "
+ "<if test=\"_databaseId == 'db2'\">(DAYS(T.${status}) - DAYS(#{now}))</if>"
+ "<if test=\"_databaseId == 'db2'\">(DAYS(T.${status}) - DAYS(CAST(#{now} as TIMESTAMP)))</if>"
+ "<if test=\"_databaseId == 'h2'\">DATEDIFF('DAY', #{now}, T.${status})</if>"
+ "<if test=\"_databaseId == 'postgres'\">DATE_PART('DAY', T.${status} - #{now})</if>"
+ " as AGE_IN_DAYS "