Change time filtering DB column

4.x.x
Pahansith Gunathilake 3 years ago
parent 007b309c71
commit cf4f45c89d

@ -773,8 +773,9 @@ public class RequestValidationUtil {
public static void validateTimeDuration(long startTimestamp, long endTimestamp) { public static void validateTimeDuration(long startTimestamp, long endTimestamp) {
if (startTimestamp > endTimestamp) { if (startTimestamp > endTimestamp) {
throw new InputValidationException( throw new InputValidationException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter startTimestamp" + new ErrorResponse.ErrorResponseBuilder().setCode(400l)
" should not be higher values than endTimestamp").build()); .setMessage("Request parameter startTimestamp should not be " +
"a higher value than endTimestamp").build());
} }
} }
} }

@ -1769,7 +1769,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
} }
if (activityPaginationRequest.getStartTimestamp() > 0 && activityPaginationRequest.getEndTimestamp() > 0) { if (activityPaginationRequest.getStartTimestamp() > 0 && activityPaginationRequest.getEndTimestamp() > 0) {
isTimeDurationFilteringProvided = true; isTimeDurationFilteringProvided = true;
sql += "AND UPDATED_TIMESTAMP BETWEEN ? AND ? "; sql += "AND CREATED_TIMESTAMP BETWEEN ? AND ? ";
} }
if (activityPaginationRequest.getType() != null) { if (activityPaginationRequest.getType() != null) {
sql += "AND TYPE = ? "; sql += "AND TYPE = ? ";
@ -1797,7 +1797,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
sql += "AND eom.UPDATED_TIMESTAMP > ? "; sql += "AND eom.UPDATED_TIMESTAMP > ? ";
} }
if (isTimeDurationFilteringProvided) { if (isTimeDurationFilteringProvided) {
sql += "AND eom.UPDATED_TIMESTAMP BETWEEN ? AND ? "; sql += "AND eom.CREATED_TIMESTAMP BETWEEN ? AND ? ";
} }
if (activityPaginationRequest.getType() != null) { if (activityPaginationRequest.getType() != null) {
sql += "AND eom.TYPE = ? "; sql += "AND eom.TYPE = ? ";
@ -1917,8 +1917,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
} }
if (activityPaginationRequest.getStartTimestamp() > 0 && activityPaginationRequest.getEndTimestamp() > 0) { if (activityPaginationRequest.getStartTimestamp() > 0 && activityPaginationRequest.getEndTimestamp() > 0) {
isTimeDurationFilteringProvided = true; isTimeDurationFilteringProvided = true;
sql += "AND UPDATED_TIMESTAMP BETWEEN ? AND ? "; sql += "AND CREATED_TIMESTAMP BETWEEN ? AND ? ";
} }
int index = 1; int index = 1;
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(index++, tenantId); stmt.setInt(index++, tenantId);

Loading…
Cancel
Save