| @@ -454,6 +454,12 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS | |||||
| OpenIIndexMap := queryUserRepoOpenIIndex(startTime.Unix(), end_unix) | OpenIIndexMap := queryUserRepoOpenIIndex(startTime.Unix(), end_unix) | ||||
| CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) | CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) | ||||
| AiModelManageMap := queryUserModel(start_unix, end_unix) | AiModelManageMap := queryUserModel(start_unix, end_unix) | ||||
| CollectDataset, CollectedDataset := queryDatasetStars(start_unix, end_unix) | |||||
| RecommendDataset := queryRecommedDataSet(start_unix, end_unix) | |||||
| CollectImage, CollectedImage := queryImageStars(start_unix, end_unix) | |||||
| RecommendImage := queryRecommedImage(start_unix, end_unix) | |||||
| DataDate := currentTimeNow.Format("2006-01-02") + " 00:01" | DataDate := currentTimeNow.Format("2006-01-02") + " 00:01" | ||||
| cond := "type != 1 and is_active=true" | cond := "type != 1 and is_active=true" | ||||
| @@ -515,6 +521,13 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS | |||||
| dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) | dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) | ||||
| dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) | dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) | ||||
| dateRecordAll.CommitModelCount = getMapValue(dateRecordAll.ID, AiModelManageMap) | dateRecordAll.CommitModelCount = getMapValue(dateRecordAll.ID, AiModelManageMap) | ||||
| dateRecordAll.CollectDataset = getMapValue(dateRecordAll.ID, CollectDataset) | |||||
| dateRecordAll.CollectedDataset = getMapValue(dateRecordAll.ID, CollectedDataset) | |||||
| dateRecordAll.RecommendDataset = getMapValue(dateRecordAll.ID, RecommendDataset) | |||||
| dateRecordAll.CollectImage = getMapValue(dateRecordAll.ID, CollectImage) | |||||
| dateRecordAll.CollectedImage = getMapValue(dateRecordAll.ID, CollectedImage) | |||||
| dateRecordAll.RecommendImage = getMapValue(dateRecordAll.ID, RecommendImage) | |||||
| dateRecordAll.UserIndex = getUserIndexFromAnalysisAll(dateRecordAll, ParaWeight) | dateRecordAll.UserIndex = getUserIndexFromAnalysisAll(dateRecordAll, ParaWeight) | ||||
| userIndexMap[dateRecordAll.ID] = dateRecordAll.UserIndex | userIndexMap[dateRecordAll.ID] = dateRecordAll.UserIndex | ||||
| if maxUserIndex < dateRecordAll.UserIndex { | if maxUserIndex < dateRecordAll.UserIndex { | ||||
| @@ -663,6 +676,12 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, | |||||
| OpenIIndexMap := queryUserRepoOpenIIndex(start_unix, end_unix) | OpenIIndexMap := queryUserRepoOpenIIndex(start_unix, end_unix) | ||||
| CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) | CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) | ||||
| AiModelManageMap := queryUserModel(start_unix, end_unix) | AiModelManageMap := queryUserModel(start_unix, end_unix) | ||||
| CollectDataset, CollectedDataset := queryDatasetStars(start_unix, end_unix) | |||||
| RecommendDataset := queryRecommedDataSet(start_unix, end_unix) | |||||
| CollectImage, CollectedImage := queryImageStars(start_unix, end_unix) | |||||
| RecommendImage := queryRecommedImage(start_unix, end_unix) | |||||
| statictisSess := xStatistic.NewSession() | statictisSess := xStatistic.NewSession() | ||||
| defer statictisSess.Close() | defer statictisSess.Close() | ||||
| @@ -734,6 +753,14 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, | |||||
| dateRecord.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) | dateRecord.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) | ||||
| dateRecord.CloudBrainRunTime = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_CloudBrainRunTime", CloudBrainTaskItemMap) | dateRecord.CloudBrainRunTime = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_CloudBrainRunTime", CloudBrainTaskItemMap) | ||||
| dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) | dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) | ||||
| dateRecord.CollectDataset = getMapValue(dateRecord.ID, CollectDataset) | |||||
| dateRecord.CollectedDataset = getMapValue(dateRecord.ID, CollectedDataset) | |||||
| dateRecord.RecommendDataset = getMapValue(dateRecord.ID, RecommendDataset) | |||||
| dateRecord.CollectImage = getMapValue(dateRecord.ID, CollectImage) | |||||
| dateRecord.CollectedImage = getMapValue(dateRecord.ID, CollectedImage) | |||||
| dateRecord.RecommendImage = getMapValue(dateRecord.ID, RecommendImage) | |||||
| dateRecord.UserIndex = getUserIndex(dateRecord, ParaWeight) | dateRecord.UserIndex = getUserIndex(dateRecord, ParaWeight) | ||||
| setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) | setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) | ||||
| _, err = statictisSess.Insert(&dateRecord) | _, err = statictisSess.Insert(&dateRecord) | ||||
| @@ -1196,6 +1223,214 @@ func queryFollow(start_unix int64, end_unix int64) (map[int64]int, map[int64]int | |||||
| return resultMap, resultFocusedByOtherMap | return resultMap, resultFocusedByOtherMap | ||||
| } | } | ||||
| func queryRecommedDataSet(start_unix int64, end_unix int64) map[int64]int { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| userIdDdatasetMap := make(map[int64]int) | |||||
| cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) + " and recommend=true" | |||||
| count, err := sess.Where(cond).Count(new(Dataset)) | |||||
| if err != nil { | |||||
| log.Info("query recommend dataset error. return.") | |||||
| return userIdDdatasetMap | |||||
| } | |||||
| var indexTotal int64 | |||||
| indexTotal = 0 | |||||
| for { | |||||
| sess.Select("id,user_id,recommend").Where(cond).Table(new(Dataset)).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) | |||||
| datasetList := make([]*Dataset, 0) | |||||
| sess.Find(&datasetList) | |||||
| log.Info("query datasetList size=" + fmt.Sprint(len(datasetList))) | |||||
| for _, datasetRecord := range datasetList { | |||||
| if _, ok := userIdDdatasetMap[datasetRecord.UserID]; !ok { | |||||
| userIdDdatasetMap[datasetRecord.UserID] = 1 | |||||
| } else { | |||||
| userIdDdatasetMap[datasetRecord.UserID] += 1 | |||||
| } | |||||
| } | |||||
| indexTotal += PAGE_SIZE | |||||
| if indexTotal >= count { | |||||
| break | |||||
| } | |||||
| } | |||||
| return userIdDdatasetMap | |||||
| } | |||||
| func queryAllDataSet() (map[int64]int64, map[int64]int64) { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| datasetUserIdMap := make(map[int64]int64) | |||||
| userIdDdatasetMap := make(map[int64]int64) | |||||
| count, err := sess.Count(new(Dataset)) | |||||
| if err != nil { | |||||
| log.Info("query dataset error. return.") | |||||
| return datasetUserIdMap, userIdDdatasetMap | |||||
| } | |||||
| var indexTotal int64 | |||||
| indexTotal = 0 | |||||
| for { | |||||
| sess.Select("id,user_id").Table(new(Dataset)).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) | |||||
| datasetList := make([]*Dataset, 0) | |||||
| sess.Find(&datasetList) | |||||
| log.Info("query datasetList size=" + fmt.Sprint(len(datasetList))) | |||||
| for _, datasetRecord := range datasetList { | |||||
| datasetUserIdMap[datasetRecord.ID] = datasetRecord.UserID | |||||
| if _, ok := userIdDdatasetMap[datasetRecord.UserID]; !ok { | |||||
| userIdDdatasetMap[datasetRecord.UserID] = 1 | |||||
| } else { | |||||
| userIdDdatasetMap[datasetRecord.UserID] += 1 | |||||
| } | |||||
| } | |||||
| indexTotal += PAGE_SIZE | |||||
| if indexTotal >= count { | |||||
| break | |||||
| } | |||||
| } | |||||
| return datasetUserIdMap, userIdDdatasetMap | |||||
| } | |||||
| func queryRecommedImage(start_unix int64, end_unix int64) map[int64]int { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| userIdImageMap := make(map[int64]int) | |||||
| cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) + " and type=5" | |||||
| count, err := sess.Where(cond).Count(new(Image)) | |||||
| if err != nil { | |||||
| log.Info("query recommend image error. return.") | |||||
| return userIdImageMap | |||||
| } | |||||
| var indexTotal int64 | |||||
| indexTotal = 0 | |||||
| for { | |||||
| sess.Select("id,uid,type").Where(cond).Table(new(Image)).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) | |||||
| imageList := make([]*Image, 0) | |||||
| sess.Find(&imageList) | |||||
| log.Info("query imageList size=" + fmt.Sprint(len(imageList))) | |||||
| for _, imageRecord := range imageList { | |||||
| if _, ok := userIdImageMap[imageRecord.UID]; !ok { | |||||
| userIdImageMap[imageRecord.UID] = 1 | |||||
| } else { | |||||
| userIdImageMap[imageRecord.UID] += 1 | |||||
| } | |||||
| } | |||||
| indexTotal += PAGE_SIZE | |||||
| if indexTotal >= count { | |||||
| break | |||||
| } | |||||
| } | |||||
| return userIdImageMap | |||||
| } | |||||
| func queryAllImage() (map[int64]int64, map[int64]int64) { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| imageUserIdMap := make(map[int64]int64) | |||||
| userIdDImageMap := make(map[int64]int64) | |||||
| count, err := sess.Count(new(Image)) | |||||
| if err != nil { | |||||
| log.Info("query image error. return.") | |||||
| return imageUserIdMap, userIdDImageMap | |||||
| } | |||||
| var indexTotal int64 | |||||
| indexTotal = 0 | |||||
| for { | |||||
| sess.Select("id,uid").Table(new(Image)).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) | |||||
| imageList := make([]*Image, 0) | |||||
| sess.Find(&imageList) | |||||
| log.Info("query imageList size=" + fmt.Sprint(len(imageList))) | |||||
| for _, imageRecord := range imageList { | |||||
| imageUserIdMap[imageRecord.ID] = imageRecord.UID | |||||
| if _, ok := userIdDImageMap[imageRecord.UID]; !ok { | |||||
| userIdDImageMap[imageRecord.UID] = 1 | |||||
| } else { | |||||
| userIdDImageMap[imageRecord.UID] += 1 | |||||
| } | |||||
| } | |||||
| indexTotal += PAGE_SIZE | |||||
| if indexTotal >= count { | |||||
| break | |||||
| } | |||||
| } | |||||
| return imageUserIdMap, userIdDImageMap | |||||
| } | |||||
| func queryDatasetStars(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| datasetCollect := make(map[int64]int) | |||||
| datasetCollected := make(map[int64]int) | |||||
| datasetUserIdMap, _ := queryAllDataSet() | |||||
| cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) | |||||
| count, err := sess.Where(cond).Count(new(DatasetStar)) | |||||
| if err != nil { | |||||
| log.Info("query follow error. return.") | |||||
| return datasetCollect, datasetCollected | |||||
| } | |||||
| var indexTotal int64 | |||||
| indexTotal = 0 | |||||
| for { | |||||
| sess.Select("id,uid,dataset_id").Table(new(DatasetStar)).Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) | |||||
| datasetStarList := make([]*DatasetStar, 0) | |||||
| sess.Find(&datasetStarList) | |||||
| log.Info("query datasetStarList size=" + fmt.Sprint(len(datasetStarList))) | |||||
| for _, datasetStarRecord := range datasetStarList { | |||||
| if _, ok := datasetCollect[datasetStarRecord.UID]; !ok { | |||||
| datasetCollect[datasetStarRecord.UID] = 1 | |||||
| } else { | |||||
| datasetCollect[datasetStarRecord.UID] += 1 | |||||
| } | |||||
| if _, ok := datasetCollected[datasetUserIdMap[datasetStarRecord.DatasetID]]; !ok { | |||||
| datasetCollected[datasetUserIdMap[datasetStarRecord.DatasetID]] = 1 | |||||
| } else { | |||||
| datasetCollected[datasetUserIdMap[datasetStarRecord.DatasetID]] += 1 | |||||
| } | |||||
| } | |||||
| indexTotal += PAGE_SIZE | |||||
| if indexTotal >= count { | |||||
| break | |||||
| } | |||||
| } | |||||
| return datasetCollect, datasetCollected | |||||
| } | |||||
| func queryImageStars(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| imageCollect := make(map[int64]int) | |||||
| imageCollected := make(map[int64]int) | |||||
| imageUserIdMap, _ := queryAllDataSet() | |||||
| cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) | |||||
| count, err := sess.Where(cond).Count(new(ImageStar)) | |||||
| if err != nil { | |||||
| log.Info("query follow error. return.") | |||||
| return imageCollect, imageCollected | |||||
| } | |||||
| var indexTotal int64 | |||||
| indexTotal = 0 | |||||
| for { | |||||
| sess.Select("id,uid,dataset_id").Table(new(ImageStar)).Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) | |||||
| imageStarList := make([]*ImageStar, 0) | |||||
| sess.Find(&imageStarList) | |||||
| log.Info("query imageStarList size=" + fmt.Sprint(len(imageStarList))) | |||||
| for _, imageStarRecord := range imageStarList { | |||||
| if _, ok := imageCollect[imageStarRecord.UID]; !ok { | |||||
| imageCollect[imageStarRecord.UID] = 1 | |||||
| } else { | |||||
| imageCollect[imageStarRecord.UID] += 1 | |||||
| } | |||||
| if _, ok := imageCollected[imageUserIdMap[imageStarRecord.ImageID]]; !ok { | |||||
| imageCollected[imageUserIdMap[imageStarRecord.ImageID]] = 1 | |||||
| } else { | |||||
| imageCollected[imageUserIdMap[imageStarRecord.ImageID]] += 1 | |||||
| } | |||||
| } | |||||
| indexTotal += PAGE_SIZE | |||||
| if indexTotal >= count { | |||||
| break | |||||
| } | |||||
| } | |||||
| return imageCollect, imageCollected | |||||
| } | |||||
| func queryDatasetSize(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { | func queryDatasetSize(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { | ||||
| sess := x.NewSession() | sess := x.NewSession() | ||||
| defer sess.Close() | defer sess.Close() | ||||