Browse Source

[Fix-5518]: The command state count interface, projectId change to projectCode (#5849)

* fix: the data analysis state count interface, projectId change to projectCode

* fix: the data analysis state count interface, projectId change to projectCode

* fix checkstyle

* fix checkstyle

* fix: the process state count page use "projectCode"

* fix: English comments

* fix: the user definition count interface, projectId change to projectCode

* fix comment

* fix: the command state count interface, projectId change to projectCode

Co-authored-by: wen-hemin <wenhemin@apache.com>
2.0.7-release
wen-hemin 3 years ago committed by GitHub
parent
commit
f1a9c4958d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java
  2. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java
  3. 19
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java
  4. 2
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java
  5. 9
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java
  6. 94
      dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/index/_source/commandStateCount.vue

15
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java

@ -136,21 +136,20 @@ public class DataAnalysisController extends BaseController {
return returnDataList(result);
}
/**
* statistical command status data
*
* @param loginUser login user
* @param startDate start date
* @param endDate end date
* @param projectId project id
* @return command state in project id
* @param projectCode project code
* @return command state in project code
*/
@ApiOperation(value = "countCommandState", notes = "COUNT_COMMAND_STATE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "startDate", value = "START_DATE", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "END_DATE", dataType = "String"),
@ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType = "Int", example = "100")
@ApiImplicitParam(name = "startDate", value = "START_DATE", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "END_DATE", dataType = "String"),
@ApiImplicitParam(name = "projectCode", value = "PROJECT_CODE", dataType = "Long", example = "100")
})
@GetMapping(value = "/command-state-count")
@ResponseStatus(HttpStatus.OK)
@ -159,9 +158,9 @@ public class DataAnalysisController extends BaseController {
public Result countCommandState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "projectId", required = false, defaultValue = "0") int projectId) {
@RequestParam(value = "projectCode", required = false, defaultValue = "0") long projectCode) {
Map<String, Object> result = dataAnalysisService.countCommandState(loginUser, projectId, startDate, endDate);
Map<String, Object> result = dataAnalysisService.countCommandState(loginUser, projectCode, startDate, endDate);
return returnDataList(result);
}

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java

@ -61,12 +61,12 @@ public interface DataAnalysisService {
* statistical command status data
*
* @param loginUser login user
* @param projectId project id
* @param projectCode project code
* @param startDate start date
* @param endDate end date
* @return command state count data
*/
Map<String, Object> countCommandState(User loginUser, int projectId, String startDate, String endDate);
Map<String, Object> countCommandState(User loginUser, long projectCode, String startDate, String endDate);
/**
* count queue state

19
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java

@ -202,18 +202,21 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
* statistical command status data
*
* @param loginUser login user
* @param projectId project id
* @param projectCode project code
* @param startDate start date
* @param endDate end date
* @return command state count data
*/
@Override
public Map<String, Object> countCommandState(User loginUser, int projectId, String startDate, String endDate) {
public Map<String, Object> countCommandState(User loginUser, long projectCode, String startDate, String endDate) {
Map<String, Object> result = new HashMap<>();
boolean checkProject = checkProject(loginUser, projectId, result);
if (!checkProject) {
return result;
if (projectCode != 0) {
Project project = projectMapper.queryByCode(projectCode);
result = projectService.checkProjectAndAuth(loginUser, project, project.getName());
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
}
/**
@ -237,8 +240,8 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
}
}
Long[] projectCodeArray = projectId == 0 ? getProjectCodesArrays(loginUser)
: new Long[] { projectMapper.selectById(projectId).getCode() };
Long[] projectCodeArray = projectCode == 0 ? getProjectCodesArrays(loginUser)
: new Long[] { projectCode };
// count normal command state
Map<CommandType, Integer> normalCountCommandCounts = commandMapper.countCommandState(loginUser.getId(), start, end, projectCodeArray)
.stream()

2
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java

@ -110,7 +110,7 @@ public class DataAnalysisControllerTest extends AbstractControllerTest {
@Test
public void testCountCommandState() throws Exception {
PowerMockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
PowerMockito.when(projectMapper.queryByCode(Mockito.any())).thenReturn(getProject("test"));
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("startDate","2019-12-01 00:00:00");

9
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java

@ -251,12 +251,18 @@ public class DataAnalysisServiceTest {
@Test
public void testCountCommandState() {
String startDate = "2020-02-11 16:02:18";
String endDate = "2020-02-11 16:03:18";
Mockito.when(projectMapper.queryByCode(Mockito.any())).thenReturn(getProject("test"));
//checkProject false
Map<String, Object> result = dataAnalysisServiceImpl.countCommandState(user, 2, startDate, endDate);
Assert.assertTrue(result.isEmpty());
putMsg(result, Status.SUCCESS, null);
Mockito.when(projectService.checkProjectAndAuth(any(), any(), any())).thenReturn(result);
List<CommandCount> commandCounts = new ArrayList<>(1);
CommandCount commandCount = new CommandCount();
commandCount.setCommandType(CommandType.START_PROCESS);
@ -266,7 +272,6 @@ public class DataAnalysisServiceTest {
Mockito.when(errorCommandMapper.countCommandState(DateUtils.getScheduleDate(startDate),
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(commandCounts);
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
Mockito.when(projectService.hasProjectAndPerm(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true);
result = dataAnalysisServiceImpl.countCommandState(user, 1, startDate, endDate);

94
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/index/_source/commandStateCount.vue

@ -1,94 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
<template>
<div class="command-state-count-model">
<div v-show="!msg">
<div class="data-area" v-spin="isSpin">
<div id="command-state-bar" style="height:500px"></div>
</div>
</div>
<div v-show="msg">
<m-no-data :msg="msg" v-if="msg" :height="530"></m-no-data>
</div>
</div>
</template>
<script>
import _ from 'lodash'
import { mapActions } from 'vuex'
import { simple } from './chartConfig'
import Chart from '@/module/ana-charts'
import mNoData from '@/module/components/noData/noData'
export default {
name: 'command-state-count',
data () {
return {
isSpin: true,
msg: ''
}
},
props: {
searchParams: Object
},
methods: {
...mapActions('projects', ['getCommandStateCount']),
_handleCommandState (res) {
let data = []
_.forEach(res.data, (v, i) => {
let key = _.keys(v)
if (key[0] === 'errorCount') {
data.push({ typeName: `${this.$t('Error command count')}`, key: v.commandState, value: v.errorCount })
}
})
_.forEach(res.data, (v, i) => {
let key = _.keys(v)
if (key[1] === 'normalCount') {
data.push({ typeName: `${this.$t('Normal command count')}`, key: v.commandState, value: v.normalCount })
}
})
const myChart = Chart.bar('#command-state-bar', data, {
title: ''
})
myChart.echart.setOption(simple)
}
},
created () {
},
watch: {
searchParams: {
deep: true,
immediate: true,
handler (o) {
this.isSpin = true
this.getCommandStateCount(o).then(res => {
this._handleCommandState(res)
this.isSpin = false
}).catch(e => {
this.msg = e.msg || 'error'
this.isSpin = false
})
}
}
},
mounted () {
},
computed: {},
components: { mNoData }
}
</script>
Loading…
Cancel
Save