Skip to content

Commit

Permalink
perf: job获取脚本列表接口响应慢 TencentBlueKing#1205
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Sep 14, 2022
1 parent 1758a92 commit 540101b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,8 @@ private List<Condition> buildScriptConditionList(ScriptQuery scriptQuery,
conditions.add(TB_SCRIPT.APP_ID.eq(ULong.valueOf(appId)));
}

Boolean isPublic = scriptQuery.getPublicScript();
int publicFlag = ScriptScopeEnum.APP.getValue();
if (isPublic != null && isPublic) {
publicFlag = ScriptScopeEnum.PUBLIC.getValue();
}
int publicFlag = scriptQuery.isPublicScript() ? ScriptScopeEnum.PUBLIC.getValue() :
ScriptScopeEnum.APP.getValue();
conditions.add(TB_SCRIPT.IS_PUBLIC.eq(UByte.valueOf(String.valueOf(publicFlag))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class ScriptQuery {
/**
* 是否公共脚本
*/
private Boolean publicScript;
private boolean publicScript;
/**
* 业务ID
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,17 @@ private void setTags(ScriptDTO script) {
setTags(Collections.singletonList(script));
}

private void setTags(List<ScriptDTO> scripts) {
private void setTags(Collection<ScriptDTO> scripts) {
if (CollectionUtils.isEmpty(scripts)) {
return;
}
ScriptDTO someScript = scripts.stream().findAny().orElse(null);
if (someScript == null) {
return;
}
long appId = someScript.getAppId();
boolean isPublicScript = someScript.isPublicScript();

Long appId = scripts.get(0).getAppId();
boolean isPublicScript = scripts.get(0).isPublicScript();
Integer resourceType = isPublicScript ? JobResourceTypeEnum.PUBLIC_SCRIPT.getValue() :
JobResourceTypeEnum.APP_SCRIPT.getValue();

Expand Down Expand Up @@ -257,7 +261,7 @@ public PageData<ScriptDTO> listPageScript(ScriptQuery scriptCondition,

private List<String> queryScriptIdsByTags(ScriptQuery query) {
List<String> matchScriptIds = new ArrayList<>();
Integer resourceType = query.getPublicScript() ? JobResourceTypeEnum.PUBLIC_SCRIPT.getValue() :
Integer resourceType = query.isPublicScript() ? JobResourceTypeEnum.PUBLIC_SCRIPT.getValue() :
JobResourceTypeEnum.APP_SCRIPT.getValue();
if (query.isUntaggedScript()) {
// untagged script
Expand Down Expand Up @@ -650,7 +654,7 @@ public void disableScript(
@Override
public Map<String, ScriptDTO> batchGetOnlineScriptVersionByScriptIds(List<String> scriptIdList) {
Map<String, ScriptDTO> scripts = scriptDAO.batchGetOnlineByScriptIds(scriptIdList);
scripts.forEach((scriptId, script) -> setTags(script));
setTags(scripts.values());
return scripts;
}

Expand Down

0 comments on commit 540101b

Please sign in to comment.