(improvement)(headless)Decrease the number of database queries to the s2_domain table. #1472

This commit is contained in:
jerryjzhang
2024-08-08 20:59:31 +08:00
parent 1608317ab3
commit f06cd0b296
5 changed files with 19 additions and 20 deletions

View File

@@ -119,25 +119,21 @@ public class DomainServiceImpl implements DomainService {
public Set<DomainResp> getDomainAuthSet(User user, AuthType authTypeEnum) {
List<DomainResp> domainResps = getDomainList();
Set<String> orgIds = userService.getUserAllOrgId(user.getName());
List<DomainResp> domainWithAuth = Lists.newArrayList();
Set<DomainResp> domainWithAuth = Sets.newHashSet();
if (authTypeEnum.equals(AuthType.ADMIN)) {
domainWithAuth = domainResps.stream()
.filter(domainResp -> checkAdminPermission(orgIds, user, domainResp))
.collect(Collectors.toList());
.collect(Collectors.toSet());
}
if (authTypeEnum.equals(AuthType.VISIBLE)) {
domainWithAuth = domainResps.stream()
.filter(domainResp -> checkViewPermission(orgIds, user, domainResp))
.collect(Collectors.toList());
}
List<Long> domainIds = domainWithAuth.stream().map(DomainResp::getId)
.collect(Collectors.toList());
//get all child domain
return getDomainChildren(domainIds).stream()
.peek(domainResp -> domainResp.setHasEditPermission(true))
.collect(Collectors.toSet());
}
return domainWithAuth;
}
private Set<DomainResp> getParentDomain(List<Long> ids) {
Set<DomainResp> domainSet = new HashSet<>();
if (CollectionUtils.isEmpty(ids)) {

View File

@@ -358,9 +358,9 @@ public class ModelServiceImpl implements ModelService {
if (modelDO == null) {
return null;
}
Map<Long, DomainResp> domainRespMap = domainService.getDomainList().stream()
.collect(Collectors.toMap(DomainResp::getId, d -> d));
return ModelConverter.convert(modelDO, domainRespMap);
DomainResp domainResp = domainService.getDomain(modelDO.getDomainId());
return ModelConverter.convert(modelDO, domainResp);
}
@Override

View File

@@ -70,9 +70,8 @@ public class ModelConverter {
return modelResp;
}
public static ModelResp convert(ModelDO modelDO, Map<Long, DomainResp> domainRespMap) {
public static ModelResp convert(ModelDO modelDO, DomainResp domainResp) {
ModelResp modelResp = convert(modelDO);
DomainResp domainResp = domainRespMap.get(modelResp.getDomainId());
if (domainResp != null) {
String fullBizNamePath = domainResp.getFullPath() + modelResp.getBizName();
modelResp.setFullPath(fullBizNamePath);

View File

@@ -1,4 +1,9 @@
s2:
schema:
cache:
enable: true
parser:
strategy: ONE_PASS_SELF_CONSISTENCY
exemplar-recall:

View File

@@ -1,4 +1,9 @@
s2:
schema:
cache:
enable: false
parser:
strategy: ONE_PASS_SELF_CONSISTENCY
exemplar-recall:
@@ -15,16 +20,10 @@ s2:
information: true
date: true
demo:
names: S2VisitsDemo,S2ArtistDemo
enableLLM: false
schema:
cache:
enable: false
authentication:
enable: true
exclude: