Browse Source

解决AI资产卡片数据统计错误bug

dev-active_learn
chenzhihang 10 months ago
parent
commit
094dd2fd42
1 changed files with 18 additions and 24 deletions
  1. +18
    -24
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java

+ 18
- 24
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java View File

@@ -89,20 +89,13 @@ public class WorkspaceServiceImpl implements WorkspaceService {
Map<String, Integer> assetCountMap = new HashMap<>();
String token = gitService.checkoutToken();
int availableRange = isPublic ? Constant.Image_Type_Pub : Constant.Image_Type_Pri;
String datasetUrl;
String modelUrl;
if (isPublic) {
// 数据集
String url = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id;
String req = httpUtils.sendGetWithToken(url, null, token);
Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req);
List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects");
assetCountMap.put("dataset", projects.size());

datasetUrl = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id;
// 模型
url = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id;
req = httpUtils.sendGetWithToken(url, null, token);
stringObjectMap = JacksonUtil.parseJSONStr2Map(req);
projects = (List<Map<String, Object>>) stringObjectMap.get("projects");
assetCountMap.put("model", projects.size());
modelUrl = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id;
} else {
Jedis jedis = new Jedis(redisHost, redisPort);
LoginUser loginUser = SecurityUtils.getLoginUser();
@@ -110,21 +103,22 @@ public class WorkspaceServiceImpl implements WorkspaceService {
String userReq = jedis.get(ci4sUsername + "_gitUserInfo");
Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq);

String url = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage";
String req = httpUtils.sendGetWithToken(url, null, token);
Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req);
List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects");
List<NewDatasetVo> collect1 = newDatasetService.convert(projects, Constant.Topic_Dataset, null, null);
assetCountMap.put("dataset", collect1.size());

url = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage";
req = httpUtils.sendGetWithToken(url, null, token);
stringObjectMap = JacksonUtil.parseJSONStr2Map(req);
projects = (List<Map<String, Object>>) stringObjectMap.get("projects");
List<ModelsVo> collect2 = modelsService.convert(projects, Constant.Topic_model, null, null);
assetCountMap.put("model", collect2.size());
datasetUrl = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage";
modelUrl = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage";
}

String req = httpUtils.sendGetWithToken(datasetUrl, null, token);
Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req);
List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects");
List<NewDatasetVo> collect1 = newDatasetService.convert(projects, Constant.Topic_Dataset, null, null);
assetCountMap.put("dataset", collect1.size());

req = httpUtils.sendGetWithToken(modelUrl, null, token);
stringObjectMap = JacksonUtil.parseJSONStr2Map(req);
projects = (List<Map<String, Object>>) stringObjectMap.get("projects");
List<ModelsVo> collect2 = modelsService.convert(projects, Constant.Topic_model, null, null);
assetCountMap.put("model", collect2.size());

// 镜像
Image image = new Image();
image.setImageType(Constant.Image_Type_Pub);


Loading…
Cancel
Save