From c62a59a56af8cafd7e830d8a37a959b45c8fca16 Mon Sep 17 00:00:00 2001 From: "chenglong.wang" Date: Wed, 11 Dec 2024 16:36:31 +0800 Subject: [PATCH] fix: Handle null values for end_time filters --- .../platform/web/controller/DashboardController.java | 8 ++++++-- .../platform/web/controller/JobFlowRunController.java | 4 +++- .../flink/platform/web/controller/JobRunController.java | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/flink-platform-web/src/main/java/com/flink/platform/web/controller/DashboardController.java b/flink-platform-web/src/main/java/com/flink/platform/web/controller/DashboardController.java index 5554050..56df2ef 100644 --- a/flink-platform-web/src/main/java/com/flink/platform/web/controller/DashboardController.java +++ b/flink-platform-web/src/main/java/com/flink/platform/web/controller/DashboardController.java @@ -45,7 +45,9 @@ public ResultInfo>> jobRunStatusCount( List> maps = jobRunService.listMaps(new QueryWrapper() .select("status, count(id) as count") .groupBy("status") - .between(nonNull(startTime) && nonNull(endTime), "stop_time", startTime, endTime) + .nested( + nonNull(startTime) && nonNull(endTime), + qw -> qw.isNull("stop_time").or().between("stop_time", startTime, endTime)) .eq("user_id", loginUser.getId())); return success(maps); } @@ -60,7 +62,9 @@ public ResultInfo>> jobFlowRunStatusCount( List> maps = jobFlowRunService.listMaps(new QueryWrapper() .select("status, count(id) as count") .groupBy("status") - .between(nonNull(startTime) && nonNull(endTime), "end_time", startTime, endTime) + .nested( + nonNull(startTime) && nonNull(endTime), + qw -> qw.isNull("end_time").or().between("end_time", startTime, endTime)) .eq("user_id", loginUser.getId())); return success(maps); } diff --git a/flink-platform-web/src/main/java/com/flink/platform/web/controller/JobFlowRunController.java b/flink-platform-web/src/main/java/com/flink/platform/web/controller/JobFlowRunController.java index 8b10116..3586384 100644 --- a/flink-platform-web/src/main/java/com/flink/platform/web/controller/JobFlowRunController.java +++ b/flink-platform-web/src/main/java/com/flink/platform/web/controller/JobFlowRunController.java @@ -94,7 +94,9 @@ public ResultInfo> page( .eq(nonNull(status), JobFlowRun::getStatus, status) .likeRight(isNotEmpty(name), JobFlowRun::getName, name) .like(isNotEmpty(tagCode), JobFlowRun::getTags, tagCode) - .between(nonNull(startTime) && nonNull(endTime), JobFlowRun::getEndTime, startTime, endTime); + .nested(nonNull(startTime) && nonNull(endTime), qw -> qw.isNull(JobFlowRun::getEndTime) + .or() + .between(JobFlowRun::getEndTime, startTime, endTime)); if ("-id".equals(sort)) { queryWrapper.orderByDesc(JobFlowRun::getId); } diff --git a/flink-platform-web/src/main/java/com/flink/platform/web/controller/JobRunController.java b/flink-platform-web/src/main/java/com/flink/platform/web/controller/JobRunController.java index 85ea419..250b8ab 100644 --- a/flink-platform-web/src/main/java/com/flink/platform/web/controller/JobRunController.java +++ b/flink-platform-web/src/main/java/com/flink/platform/web/controller/JobRunController.java @@ -83,7 +83,10 @@ public ResultInfo> page( .eq(nonNull(jobId), JobRunInfo::getJobId, jobId) .eq(nonNull(status), JobRunInfo::getStatus, status) .likeRight(nonNull(name), JobRunInfo::getName, name) - .between(nonNull(startTime) && nonNull(endTime), JobRunInfo::getEndTime, startTime, endTime); + .nested(nonNull(startTime) && nonNull(endTime), qw -> qw.isNull(JobRunInfo::getEndTime) + .or() + .between(JobRunInfo::getEndTime, startTime, endTime)); + if ("-id".equals(sort)) { queryWrapper.orderByDesc(JobRunInfo::getId); }