yangyichao-mango commented on a change in pull request #3184:
URL:
https://github.com/apache/incubator-dolphinscheduler/pull/3184#discussion_r453298636
##########
File path:
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
##########
@@ -1853,4 +1937,16 @@ public String formatTaskAppId(TaskInstance taskInstance){
taskInstance.getId());
}
+ /**
+ * return top n SUCCESS process instance order by running time which
started between startTime and endTime
+ *
+ * @param size
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ public List<ProcessInstance> topNLongestRunningProcessInstance(int size,
Date startTime, Date endTime) {
Review comment:
> can I do the check like this?
> `
if(size<=0||startTime==null||endTime==null||startTime.getTime()>endTime.getTime()){
return new ArrayList<ProcessInstance>(); }`
Hi,
You should write this method in
`org.apache.dolphinscheduler.api.service.ProcessInstanceService` of
`dolphinscheduler-api` module. And you can handle this in below template[1]
like the other method in `ProcessInstanceService` if you like.
It will be better to add the comment in every method.
Thx a lot for your contribution.
If you have any question or suggestion, please put forward.
[1] template:
```
public Map<String, Object> listTopNLongestRunningProcessInstances(int size,
Date startTime, Date endTime) {
Map<String, Object> result = new HashMap<>();
if (0 > size) {
putMsg(result, Status.NEGATIVE_SIZE_NUMBER_ERROR, size);
return result;
}
if (Objects.isNull(startTime)) {
putMsg(result, Status.DATA_IS_NULL, Constants.START_TIME);
return result;
}
if (Objects.isNull(endTime)) {
putMsg(result, Status.DATA_IS_NULL, Constants.END_TIME);
return result;
}
if (startTime.getTime() > endTime.getTime()) {
putMsg(result, Status.START_TIME_BIGGER_THAN_END_TIME_ERROR,
startTime, endTime);
return result;
}
List<ProcessInstance> processInstances =
processInstanceMapper.queryTopNProcessInstance(size, startTime, endTime,
ExecutionStatus.SUCCESS);
result.put(Constants.DATA_LIST, processInstances);
putMsg(result, Status.SUCCESS);
return result;
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]