Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: batch get variable from mysql by view Ids #2189

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.util.Collection;
import java.util.List;
import java.util.Set;

@Mapper
public interface VariableMapperExt extends VariableMapper {
Expand Down Expand Up @@ -41,6 +42,14 @@ public interface VariableMapperExt extends VariableMapper {
})
List<Variable> selectViewQueryVariables(String viewId);

@Select({
"<script>",
"SELECT * FROM variable WHERE `type`='QUERY' AND view_id in ",
"<foreach collection='viewIds' item='item' index='index' open='(' close=')' separator=','> #{item} </foreach> ;",
"</script>"
})
List<Variable> selectViewQueryVariablesByViewIds(Set<String> viewIds);

@Select({
"SELECT * FROM variable WHERE org_id = #{orgId} AND view_id is NULL"
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public interface VariableService extends BaseCRUDService<Variable, VariableMappe

List<Variable> listViewQueryVariables(String viewId);

List<Variable> listViewQueryVariablesByViewIds(Set<String> viewIds);

boolean deleteByIds(Set<String> variableIds);

boolean batchUpdate(List<VariableUpdateParam> updateParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ public DashboardDetail getDashboardDetail(String dashboardId) {
//variables
LinkedList<Variable> variables = new LinkedList<>(variableService.listOrgQueryVariables(dashboard.getOrgId()));
if (!CollectionUtils.isEmpty(viewIds)) {
for (String viewId : viewIds) {
variables.addAll(variableService.listViewQueryVariables(viewId));
}
variables.addAll(variableService.listViewQueryVariablesByViewIds(viewIds));
}
dashboardDetail.setQueryVariables(variables);
// download permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ public List<Variable> listViewQueryVariables(String viewId) {
return variableMapper.selectViewQueryVariables(viewId);
}

@Override
public List<Variable> listViewQueryVariablesByViewIds(Set<String> viewIds) {
return variableMapper.selectViewQueryVariablesByViewIds(viewIds);
}

@Override
@Transactional
Expand Down