yangyichao-mango commented on a change in pull request #3315:
URL:
https://github.com/apache/incubator-dolphinscheduler/pull/3315#discussion_r462238722
##########
File path:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java
##########
@@ -204,6 +205,29 @@ public Result queryProcessInstanceById(@ApiIgnore
@RequestAttribute(value = Cons
return returnDataList(result);
}
+ @ApiOperation(value = "queryTopNLongestRunningProcessInstance", notes =
"QUERY_TOPN_LONGEST_RUNNING_PROCESS_INSTANCE_NOTES")
Review comment:
Hi,
It will be better to add the java docs like[1] here. can you do it?
[1]

##########
File path:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
##########
@@ -98,6 +98,53 @@
@Autowired
UsersService usersService;
+ /**
+ * return top n SUCCESS process instance order by running time which
started between startTime and endTime
+ * @param loginUser
+ * @param projectName
+ * @param size
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ public Map<String, Object> queryTopNLongestRunningProcessInstance(User
loginUser,String projectName,int size, String startTime, String endTime) {
+ Map<String, Object> result = new HashMap<>();
+
+ Project project = projectMapper.queryByName(projectName);
+ Map<String, Object> checkResult =
projectService.checkProjectAndAuth(loginUser, project, projectName);
+ Status resultEnum = (Status) checkResult.get(Constants.STATUS);
+ if (resultEnum != Status.SUCCESS) {
+ return checkResult;
+ }
+
+ if (0 > size) {
+ putMsg(result, Status.NEGTIVE_SIZE_NUMBER_ERROR, size);
+ return result;
+ }
+ if (Objects.isNull(startTime)) {
+ putMsg(result, Status.DATA_IS_NULL, Constants.START_TIME);
+ return result;
+ }
+ Date start=DateUtils.stringToDate(startTime);
+ if (Objects.isNull(endTime)) {
+ putMsg(result, Status.DATA_IS_NULL, Constants.END_TIME);
+ return result;
+ }
+ Date end=DateUtils.stringToDate(endTime);
Review comment:
```suggestion
Date end = DateUtils.stringToDate(endTime);
```
##########
File path:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
##########
@@ -98,6 +98,53 @@
@Autowired
UsersService usersService;
+ /**
+ * return top n SUCCESS process instance order by running time which
started between startTime and endTime
+ * @param loginUser
+ * @param projectName
+ * @param size
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ public Map<String, Object> queryTopNLongestRunningProcessInstance(User
loginUser,String projectName,int size, String startTime, String endTime) {
+ Map<String, Object> result = new HashMap<>();
+
+ Project project = projectMapper.queryByName(projectName);
+ Map<String, Object> checkResult =
projectService.checkProjectAndAuth(loginUser, project, projectName);
+ Status resultEnum = (Status) checkResult.get(Constants.STATUS);
+ if (resultEnum != Status.SUCCESS) {
+ return checkResult;
+ }
+
+ if (0 > size) {
+ putMsg(result, Status.NEGTIVE_SIZE_NUMBER_ERROR, size);
+ return result;
+ }
+ if (Objects.isNull(startTime)) {
+ putMsg(result, Status.DATA_IS_NULL, Constants.START_TIME);
+ return result;
+ }
+ Date start=DateUtils.stringToDate(startTime);
Review comment:
```suggestion
Date start = DateUtils.stringToDate(startTime);
```
##########
File path:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
##########
@@ -98,6 +98,53 @@
@Autowired
UsersService usersService;
+ /**
+ * return top n SUCCESS process instance order by running time which
started between startTime and endTime
+ * @param loginUser
+ * @param projectName
+ * @param size
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ public Map<String, Object> queryTopNLongestRunningProcessInstance(User
loginUser,String projectName,int size, String startTime, String endTime) {
Review comment:
```suggestion
public Map<String, Object> queryTopNLongestRunningProcessInstance(User
loginUser, String projectName, int size, String startTime, String endTime) {
```
##########
File path:
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
##########
@@ -978,6 +978,8 @@ private Constants() {
public static final int NORAML_NODE_STATUS = 0;
public static final int ABNORMAL_NODE_STATUS = 1;
+ public static final String START_TIME="start time";
+ public static final String END_TIME="end time";
Review comment:
```suggestion
public static final String START_TIME = "start time";
public static final String END_TIME = "end time";
```
##########
File path:
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java
##########
@@ -147,6 +147,40 @@ public void testQueryProcessInstanceList() {
}
+ @Test
+ public void testQueryTopNLongestRunningProcessInstance(){
Review comment:
```suggestion
public void testQueryTopNLongestRunningProcessInstance() {
```
##########
File path:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
##########
@@ -98,6 +98,53 @@
@Autowired
UsersService usersService;
+ /**
+ * return top n SUCCESS process instance order by running time which
started between startTime and endTime
+ * @param loginUser
+ * @param projectName
+ * @param size
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ public Map<String, Object> queryTopNLongestRunningProcessInstance(User
loginUser,String projectName,int size, String startTime, String endTime) {
+ Map<String, Object> result = new HashMap<>();
+
+ Project project = projectMapper.queryByName(projectName);
+ Map<String, Object> checkResult =
projectService.checkProjectAndAuth(loginUser, project, projectName);
+ Status resultEnum = (Status) checkResult.get(Constants.STATUS);
+ if (resultEnum != Status.SUCCESS) {
+ return checkResult;
+ }
+
+ if (0 > size) {
+ putMsg(result, Status.NEGTIVE_SIZE_NUMBER_ERROR, size);
+ return result;
+ }
+ if (Objects.isNull(startTime)) {
+ putMsg(result, Status.DATA_IS_NULL, Constants.START_TIME);
+ return result;
+ }
+ Date start=DateUtils.stringToDate(startTime);
+ if (Objects.isNull(endTime)) {
+ putMsg(result, Status.DATA_IS_NULL, Constants.END_TIME);
+ return result;
+ }
+ Date end=DateUtils.stringToDate(endTime);
+ if(start == null || end == null){
Review comment:
```suggestion
if(start == null || end == null) {
```
##########
File path:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java
##########
@@ -204,6 +205,29 @@ public Result queryProcessInstanceById(@ApiIgnore
@RequestAttribute(value = Cons
return returnDataList(result);
}
+ @ApiOperation(value = "queryTopNLongestRunningProcessInstance", notes =
"QUERY_TOPN_LONGEST_RUNNING_PROCESS_INSTANCE_NOTES")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "size", value = "PROCESS_INSTANCE_SIZE",
dataType = "Int", example = "10"),
+ @ApiImplicitParam(name = "startTime", value =
"PROCESS_INSTANCE_START_TIME", dataType = "String"),
+ @ApiImplicitParam(name = "endTime", value =
"PROCESS_INSTANCE_END_TIME", dataType = "String"),
+ })
+ @GetMapping(value = "/top-n")
+ @ResponseStatus(HttpStatus.OK)
+ @ApiException(QUERY_PROCESS_INSTANCE_BY_ID_ERROR)
+ public Result<ProcessInstance>
queryTopNLongestRunningProcessInstance(@ApiIgnore @RequestAttribute(value =
Constants.SESSION_USER) User loginUser,
+ @ApiParam(name =
"projectName", value = "PROJECT_NAME", required = true) @PathVariable String
projectName,
+ @RequestParam("size")
Integer size,
+ @RequestParam(value =
"startTime",required = true) String startTime,
+ @RequestParam(value =
"endTime",required = true) String endTime
+
+ ){
Review comment:
```suggestion
) {
```
----------------------------------------------------------------
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]