Skip to content

Commit

Permalink
[Feature][Server] Improve JobList Page (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxzuo authored Oct 13, 2023
1 parent 868ec34 commit d9ed433
Show file tree
Hide file tree
Showing 16 changed files with 316 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,19 @@ public Object listByDataSourceId(@PathVariable Long datasourceId) {
@ApiOperation(value = "get job page")
@GetMapping(value = "/page")
public Object page(@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam(value = "schemaSearch", required = false) String schemaSearch,
@RequestParam(value = "tableSearch", required = false) String tableSearch,
@RequestParam(value = "columnSearch", required = false) String columnSearch,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam("datasourceId") Long datasourceId,
@RequestParam(value = "type", required = false) Integer type,
@RequestParam("pageNumber") Integer pageNumber,
@RequestParam("pageSize") Integer pageSize) {
if (type == null) {
type = 0;
}
return jobService.getJobPage(searchVal, datasourceId, type, pageNumber, pageSize);
return jobService.getJobPage(searchVal, schemaSearch, tableSearch, columnSearch, startTime, endTime, datasourceId, type, pageNumber, pageSize);
}

@ApiOperation(value = "execute job")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.datavines.server.api.dto.vo;


import lombok.Data;

@Data
public class JobExecutionStat {

private Long jobId;

/**
* 总执行次数
*/
private Integer totalCount;

/**
* 执行成功次数
*/
private Integer successCount;

/**
* 执行失败次数
*/
private Integer failCount;

/**
* 首次执行时间
*/
private String firstJobExecutionTime;

/**
* 最近一次执行时间
*/
private String lastJobExecutionTime;


}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,36 @@ public class JobVO implements Serializable {
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime updateTime;

/**
* cron 表达式
*/
private String cronExpression;

/**
* 总执行次数
*/
private Integer totalCount;

/**
* 执行成功次数
*/
private Integer successCount;

/**
* 执行失败次数
*/
private Integer failCount;

/**
* 首次执行时间
*/
private String firstJobExecutionTime;

/**
* 最近一次执行时间
*/
private String lastJobExecutionTime;

public String getType() {
return type.getDescription();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.datavines.server.api.dto.vo.JobExecutionAggItem;
import io.datavines.server.api.dto.vo.JobExecutionStat;
import io.datavines.server.api.dto.vo.JobExecutionTrendBarItem;
import io.datavines.server.api.dto.vo.JobExecutionVO;
import org.apache.ibatis.annotations.*;
Expand Down Expand Up @@ -52,4 +53,7 @@ List<JobExecutionTrendBarItem> getJobExecutionTrendBar(@Param("datasourceId") Lo
@Param("metricType") String metricType, @Param("schemaName") String schemaName,
@Param("tableName") String tableName, @Param("columnName") String columnName,
@Param("startTime") String startTime, @Param("endTime") String endTime);


JobExecutionStat getJobExecutionStat(@Param("jobId") Long jobId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,14 @@ IPage<JobVO> getJobPage(Page<JobVO> page,
@Param("searchVal") String searchVal,
@Param("datasourceId") Long datasourceId,
@Param("type") Integer type);

IPage<JobVO> getJobPageSelect(Page<JobVO> page,
@Param("searchVal") String searchVal,
@Param("schemaSearch") String schemaSearch,
@Param("tableSearch") String tableSearch,
@Param("columnSearch") String columnSearch,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("datasourceId") Long datasourceId,
@Param("type") Integer type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import io.datavines.common.entity.job.SubmitJob;
import io.datavines.server.api.dto.bo.job.JobExecutionDashboardParam;
import io.datavines.server.api.dto.bo.job.JobExecutionPageParam;
import io.datavines.server.api.dto.vo.JobExecutionAggItem;
import io.datavines.server.api.dto.vo.JobExecutionTrendBar;
import io.datavines.server.api.dto.vo.JobExecutionVO;
import io.datavines.server.api.dto.vo.MetricExecutionDashBoard;
import io.datavines.server.api.dto.vo.*;
import io.datavines.server.repository.entity.JobExecution;
import io.datavines.core.exception.DataVinesServerException;

Expand Down Expand Up @@ -61,4 +58,6 @@ public interface JobExecutionService extends IService<JobExecution> {
List<JobExecutionAggItem> getJobExecutionAggPie(JobExecutionDashboardParam dashboardParam);

JobExecutionTrendBar getJobExecutionTrendBar(JobExecutionDashboardParam dashboardParam);

JobExecutionStat getJobExecutionStat(Long jobId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ public interface JobService extends IService<Job> {

List<Job> listByDataSourceId(Long dataSourceId);

IPage<JobVO> getJobPage(String searchVal, Long dataSourceId, Integer type, Integer pageNumber, Integer pageSize);
IPage<JobVO> getJobPage(String searchVal,
String schemaSearch,
String tableSearch,
String columnSearch,
String startTime,
String endTime,
Long dataSourceId,
Integer type,
Integer pageNumber,
Integer pageSize);

boolean execute(Long jobId, LocalDateTime scheduleTime) throws DataVinesServerException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,11 @@ public JobExecutionTrendBar getJobExecutionTrendBar(JobExecutionDashboardParam d

return trendBar;
}

@Override
public JobExecutionStat getJobExecutionStat(Long jobId) {
return baseMapper.getJobExecutionStat(jobId);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import io.datavines.server.api.dto.bo.job.DataProfileJobCreateOrUpdate;
import io.datavines.server.api.dto.bo.job.JobCreate;
import io.datavines.server.api.dto.bo.job.JobUpdate;
import io.datavines.server.api.dto.vo.JobExecutionStat;
import io.datavines.server.api.dto.vo.JobVO;
import io.datavines.server.api.dto.vo.SlaConfigVO;
import io.datavines.server.api.dto.vo.SlaVO;
Expand Down Expand Up @@ -439,14 +440,28 @@ public int deleteByDataSourceId(long dataSourceId) {
}

@Override
public IPage<JobVO> getJobPage(String searchVal, Long dataSourceId, Integer type, Integer pageNumber, Integer pageSize) {
public IPage<JobVO> getJobPage(String searchVal,
String schemaSearch,
String tableSearch,
String columnSearch,
String startTime,
String endTime,
Long dataSourceId, Integer type, Integer pageNumber, Integer pageSize) {
Page<JobVO> page = new Page<>(pageNumber, pageSize);
IPage<JobVO> jobs = baseMapper.getJobPage(page, searchVal, dataSourceId, type);
IPage<JobVO> jobs = baseMapper.getJobPageSelect(page, searchVal, schemaSearch, tableSearch, columnSearch, startTime, endTime, dataSourceId, type);
List<JobVO> jobList = jobs.getRecords();
if (CollectionUtils.isNotEmpty(jobList)) {
for(JobVO jobVO: jobList) {
List<SlaVO> slaList = slaService.getSlaByJobId(jobVO.getId());
jobVO.setSlaList(slaList);
JobExecutionStat jobExecutionStat = jobExecutionService.getJobExecutionStat(jobVO.getId());
if(jobExecutionStat != null){
jobVO.setTotalCount(jobExecutionStat.getTotalCount());
jobVO.setSuccessCount(jobExecutionStat.getSuccessCount());
jobVO.setFailCount(jobExecutionStat.getFailCount());
jobVO.setFirstJobExecutionTime(jobExecutionStat.getFirstJobExecutionTime());
jobVO.setLastJobExecutionTime(jobExecutionStat.getLastJobExecutionTime());
}
}
}
return jobs;
Expand Down
16 changes: 16 additions & 0 deletions datavines-server/src/main/resources/mapper/JobExecutionMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,20 @@
<select id="getJobExecutionTrendBar" resultType="io.datavines.server.api.dto.vo.JobExecutionTrendBarItem">
select p.create_date, status, count(1) as num from (<include refid="basic_sql_2"/>) p group by p.create_date,p.status order by create_date
</select>

<select id="getJobExecutionStat" resultType="io.datavines.server.api.dto.vo.JobExecutionStat">
select p.job_id,
count(1) as total_count,
sum(if(status = 6, 1, 0)) as fail_count,
sum(if(status = 7, 1, 0)) as success_count,
max(start_time) as last_job_execution_time,
min(start_time) as first_job_execution_time
from dv_job_execution p
<where>
<if test="jobId != null">
and job_id = #{jobId}
</if>
</where>
group by p.job_id
</select>
</mapper>
32 changes: 31 additions & 1 deletion datavines-server/src/main/resources/mapper/JobMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
</sql>

<select id="getJobPage" resultType="io.datavines.server.api.dto.vo.JobVO">
select p.id, p.name, p.schema_name ,p.table_name,p.column_name, p.type, u.username as updater, p.update_time from (<include refid="basic_sql"/>) p left join `dv_user` u on u.id = p.create_by
select p.id, p.name, p.schema_name ,p.table_name,p.column_name, p.type, u.username as updater, p.update_time, s.cron_expression from (<include refid="basic_sql"/>) p left join `dv_user` u on u.id = p.create_by
left join `dv_job_schedule` s on p.id = s.job_id and s.status = 1
<where>
<if test="searchVal != null">
LOWER(p.`name`) LIKE CONCAT(CONCAT('%', LOWER(#{searchVal})), '%')
Expand All @@ -34,4 +35,33 @@
order by p.update_time desc

</select>

<select id="getJobPageSelect" resultType="io.datavines.server.api.dto.vo.JobVO">
select p.id, p.name, p.schema_name ,p.table_name,p.column_name, p.type, u.username as updater, p.update_time, s.cron_expression
from (<include refid="basic_sql"/>) p left join `dv_user` u on u.id = p.create_by
left join `dv_job_schedule` s on p.id = s.job_id and s.status = 1
<where>
<if test="searchVal != null and searchVal != ''">
LOWER(p.`name`) LIKE CONCAT(CONCAT('%', LOWER(#{searchVal})), '%')
</if>
<if test="schemaSearch != null and schemaSearch != ''">
LOWER(p.schema_name) LIKE CONCAT(CONCAT('%', LOWER(#{schemaSearch})), '%')
</if>
<if test="tableSearch != null and tableSearch != ''">
LOWER(p.table_name) LIKE CONCAT(CONCAT('%', LOWER(#{tableSearch})), '%')
</if>
<if test="columnSearch != null and columnSearch != ''">
LOWER(p.column_name) LIKE CONCAT(CONCAT('%', LOWER(#{columnSearch})), '%')
</if>
<if test="startTime != null and startTime != ''">
and p.update_time &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and p.update_time &lt;= #{endTime}
</if>
</where>
order by p.update_time desc

</select>

</mapper>
2 changes: 1 addition & 1 deletion datavines-ui/Editor/components/Database/Detail/runs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Index = (props: any, ref:any) => {
}];
const getData = async () => {
setLoading(true);
const res = await $http.get('/job/execution/page', {
const res = await $http.post('/job/execution/page', {
jobId: id,
pageNumber: 1,
pageSize: 999,
Expand Down
4 changes: 4 additions & 0 deletions datavines-ui/src/locale/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export default {
jobs_task_error_data_view: 'ErrorData',
jobs_task_log_btn: 'Log',
jobs_task_result_btn: 'Result',
jobs_task_success_count: 'Success Count',
jobs_task_fail_count: 'Fail Count',
jobs_task_last_time: 'Last Job Execution Time',

jobs_task_check_result: 'Check Result',
jobs_task_check_subject: 'Check Subject',
Expand Down Expand Up @@ -221,6 +224,7 @@ export default {
job_variance: 'Variance',

job_choose_col: 'Choose Col',
job_search_col: 'Search Col',
job_profile_schedule: 'Schedule',
job_profile_execution_history: 'Execution History',
jobs_status: 'Execution Status',
Expand Down
4 changes: 4 additions & 0 deletions datavines-ui/src/locale/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export default {
jobs_task_error_data_view: '查看错误数据',
jobs_task_log_btn: '日志',
jobs_task_result_btn: '检查结果',
jobs_task_success_count: '执行成功数',
jobs_task_fail_count: '执行失败数',
jobs_task_last_time: '最近一次执行检查的时间',

jobs_task_check_result: '检查结果',
jobs_task_check_subject: '检查对象',
Expand Down Expand Up @@ -223,6 +226,7 @@ export default {
job_profile_schedule: '定时调度配置',
jobs_status: '执行状态',
jobs_execution_time: '执行时间',
job_search_col: '搜索列',

warn_sLAs_name: '名称',
warn_sLAs_type: '类型',
Expand Down
Loading

0 comments on commit d9ed433

Please sign in to comment.