@@ -291,7 +291,7 @@ func ModifyModelStatus(id string, modelSize int64, status int, modelPath string, | |||
var sess *xorm.Session | |||
sess = x.ID(id) | |||
defer sess.Close() | |||
re, err := sess.Cols("size", "status", "path").Update(&AiModelManage{ | |||
re, err := sess.Cols("size", "status", "path", "status_desc").Update(&AiModelManage{ | |||
Size: modelSize, | |||
Status: status, | |||
Path: modelPath, | |||
@@ -374,6 +374,12 @@ func QueryModel(opts *AiModelQueryOptions) ([]*AiModelManage, int64, error) { | |||
) | |||
} | |||
if (opts.Status) >= 0 { | |||
cond = cond.And( | |||
builder.Eq{"ai_model_manage.status": opts.Status}, | |||
) | |||
} | |||
count, err := sess.Where(cond).Count(new(AiModelManage)) | |||
if err != nil { | |||
return nil, 0, fmt.Errorf("Count: %v", err) | |||
@@ -64,6 +64,18 @@ func QueryInvitaionPage(start int, pageSize int) ([]*Invitation, int64) { | |||
return invitationList, allCount | |||
} | |||
func QueryInvitaionByTime(startTime int64, endTime int64) []*Invitation { | |||
statictisSess := xStatistic.NewSession() | |||
defer statictisSess.Close() | |||
cond := "created_unix >=" + fmt.Sprint(startTime) + " and created_unix <=" + fmt.Sprint(endTime) | |||
invitationList := make([]*Invitation, 0) | |||
if err := statictisSess.Table(new(Invitation)).Where(cond).OrderBy("created_unix desc"). | |||
Find(&invitationList); err != nil { | |||
return nil | |||
} | |||
return invitationList | |||
} | |||
func InsertInvitaion(invitationUser *Invitation) error { | |||
statictisSess := xStatistic.NewSession() | |||
defer statictisSess.Close() | |||
@@ -72,7 +72,7 @@ your_starred=已点赞 | |||
your_settings=设置 | |||
invite_friends=邀请好友 | |||
your_friend=您的好友 | |||
invite_you_to_join_the_OpenI_AI_Collaboration_Platform_and_enjoy_abundant_free_computing_resources=邀请你加入启智社区AI协作平台,畅享充沛的免费算力资源! | |||
invite_you_to_join_the_OpenI_AI_Collaboration_Platform_and_enjoy_abundant_free_computing_resources=邀请您加入启智社区AI协作平台,畅享充沛的免费算力资源! | |||
recommender=推荐人 | |||
all=所有 | |||
@@ -581,6 +581,8 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
m.Get("/query_invitation_last_month", operationReq, repo_ext.QueryInvitationLastMonth) | |||
m.Get("/query_invitation_yesterday", operationReq, repo_ext.QueryInvitationYesterday) | |||
m.Get("/query_invitation_all", operationReq, repo_ext.QueryInvitationAll) | |||
m.Get("/query_invitation_userdefine", operationReq, repo_ext.QueryUserDefineInvitationPage) | |||
m.Get("/download_invitation_detail", operationReq, repo_ext.DownloadInvitationDetail) | |||
//cloudbrain board | |||
@@ -980,7 +982,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
m.Get("", repo.GetModelArtsTrainJobVersion) | |||
m.Post("/stop_version", cloudbrain.AdminOrOwnerOrJobCreaterRightForTrain, repo_ext.GrampusStopJob) | |||
m.Get("/log", repo_ext.GrampusGetLog) | |||
m.Get("/download_log", cloudbrain.AdminOrOwnerOrJobCreaterRightForTrain, repo_ext.GrampusDownloadLog) | |||
m.Get("/download_log", cloudbrain.AdminOrJobCreaterRightForTrain, repo_ext.GrampusDownloadLog) | |||
}) | |||
}) | |||
}, reqRepoReader(models.UnitTypeCloudBrain)) | |||
@@ -379,7 +379,11 @@ func CloudbrainDownloadLogFile(ctx *context.Context) { | |||
return | |||
} | |||
prefix := "/" + setting.CBCodePathPrefix + job.JobName + "/model" | |||
logDir := "/model" | |||
if job.JobType == string(models.JobTypeInference) { | |||
logDir = cloudbrain.ResultPath | |||
} | |||
prefix := "/" + setting.CBCodePathPrefix + job.JobName + logDir | |||
files, err := storage.GetOneLevelAllObjectUnderDirMinio(setting.Attachment.Minio.Bucket, prefix, "") | |||
if err != nil { | |||
log.Error("query cloudbrain model failed: %v", err) | |||
@@ -348,6 +348,7 @@ func QueryModelByParameters(repoId int64, page int) ([]*models.AiModelManage, in | |||
RepoID: repoId, | |||
Type: -1, | |||
New: MODEL_LATEST, | |||
Status: -1, | |||
}) | |||
} | |||
@@ -701,6 +702,7 @@ func SetModelCount(ctx *context.Context) { | |||
RepoID: repoId, | |||
Type: Type, | |||
New: MODEL_LATEST, | |||
Status: -1, | |||
}) | |||
ctx.Data["MODEL_COUNT"] = count | |||
} | |||
@@ -774,6 +776,7 @@ func ShowModelPageInfo(ctx *context.Context) { | |||
RepoID: repoId, | |||
Type: Type, | |||
New: MODEL_LATEST, | |||
Status: -1, | |||
}) | |||
if err != nil { | |||
ctx.ServerError("Cloudbrain", err) | |||
@@ -851,6 +854,7 @@ func QueryModelListForPredict(ctx *context.Context) { | |||
RepoID: repoId, | |||
Type: ctx.QueryInt("type"), | |||
New: -1, | |||
Status: 0, | |||
}) | |||
if err != nil { | |||
ctx.ServerError("Cloudbrain", err) | |||
@@ -1551,7 +1551,6 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
}) | |||
} | |||
task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, PreVersionName) | |||
if err != nil { | |||
log.Error("GetCloudbrainByJobIDAndVersionName(%s) failed:%v", jobID, err.Error()) | |||
@@ -2322,6 +2321,7 @@ func InferenceJobIndex(ctx *context.Context) { | |||
RepoID: repoId, | |||
Type: Type, | |||
New: MODEL_LATEST, | |||
Status: 0, | |||
}) | |||
ctx.Data["MODEL_COUNT"] = model_count | |||
@@ -2402,6 +2402,7 @@ func inferenceJobNewDataPrepare(ctx *context.Context) error { | |||
RepoID: repoId, | |||
Type: Type, | |||
New: MODEL_LATEST, | |||
Status: 0, | |||
}) | |||
ctx.Data["MODEL_COUNT"] = model_count | |||
ctx.Data["datasetType"] = models.TypeCloudBrainTwo | |||
@@ -4,6 +4,8 @@ import ( | |||
"fmt" | |||
"net/http" | |||
"net/url" | |||
"sort" | |||
"time" | |||
"code.gitea.io/gitea/models" | |||
"code.gitea.io/gitea/modules/context" | |||
@@ -123,6 +125,9 @@ func DownloadInvitationDetail(ctx *context.Context) { | |||
for _, userRecord := range re { | |||
row++ | |||
userRecord.Name = userNameMap[userRecord.UserID] | |||
if userRecord.Name == "" { | |||
userRecord.Name = "已注销" | |||
} | |||
writeInvitationDetailExcel(row, xlsx, sheetName, userRecord) | |||
} | |||
indexTotal += PAGE_SIZE | |||
@@ -271,14 +276,156 @@ func QueryInvitationAll(ctx *context.Context) { | |||
queryDataFromStaticTable(ctx, "public.user_business_analysis_all", new(models.UserBusinessAnalysisAll)) | |||
} | |||
// func queryData(ctx *context.Context, startTime int64, endTime int64) { | |||
// page, pageSize := getPageInfo(ctx) | |||
// result, count := models.QueryInvitaionPage(startTime, endTime, (page-1)*pageSize, pageSize) | |||
// mapInterface := make(map[string]interface{}) | |||
// mapInterface["data"] = result | |||
// mapInterface["count"] = count | |||
// ctx.JSON(http.StatusOK, mapInterface) | |||
// } | |||
func QueryUserDefineInvitationPage(ctx *context.Context) { | |||
startDate := ctx.Query("startDate") | |||
endDate := ctx.Query("endDate") | |||
startTime, _ := time.ParseInLocation("2006-01-02", startDate, time.Local) | |||
//startTime = startTime.UTC() | |||
endTime, _ := time.ParseInLocation("2006-01-02", endDate, time.Local) | |||
queryData(ctx, startTime, endTime) | |||
} | |||
func queryData(ctx *context.Context, startTime time.Time, endTime time.Time) { | |||
page, pageSize := getPageInfo(ctx) | |||
IsReturnFile := ctx.QueryBool("IsReturnFile") | |||
dbResult := models.QueryInvitaionByTime(startTime.Unix(), endTime.Unix()) | |||
invitaionNumMap := make(map[int64]int, 0) | |||
allUserIds := make([]int64, 0) | |||
for _, record := range dbResult { | |||
if _, ok := invitaionNumMap[record.SrcUserID]; !ok { | |||
invitaionNumMap[record.SrcUserID] = 1 | |||
} else { | |||
invitaionNumMap[record.SrcUserID] = invitaionNumMap[record.SrcUserID] + 1 | |||
} | |||
} | |||
invitaionNumList := make([]models.Invitation, 0) | |||
for key, value := range invitaionNumMap { | |||
invi := models.Invitation{ | |||
SrcUserID: key, | |||
InvitationUserNum: value, | |||
} | |||
invitaionNumList = append(invitaionNumList, invi) | |||
allUserIds = append(allUserIds, key) | |||
} | |||
sort.Slice(invitaionNumList, func(i, j int) bool { | |||
return invitaionNumList[i].InvitationUserNum > invitaionNumList[j].InvitationUserNum | |||
}) | |||
if IsReturnFile { | |||
xlsx := excelize.NewFile() | |||
sheetName := ctx.Tr("user.static.invitationsheetname") | |||
index := xlsx.NewSheet(sheetName) | |||
xlsx.DeleteSheet("Sheet1") | |||
excelHeader := getInvitationExcelHeader(ctx) | |||
for k, v := range excelHeader { | |||
//设置单元格的值 | |||
xlsx.SetCellValue(sheetName, k, v) | |||
} | |||
end := 100 | |||
userMap := make(map[int64]*models.User, 0) | |||
log.Info("len(allUserIds)=" + fmt.Sprint(len(allUserIds))) | |||
for i := 0; i < len(allUserIds); i += 100 { | |||
if end >= len(allUserIds) { | |||
end = len(allUserIds) | |||
} | |||
log.Info("i=" + fmt.Sprint(i) + " end=" + fmt.Sprint(end)) | |||
if i == end { | |||
break | |||
} | |||
userList, err := models.GetUsersByIDs(allUserIds[i:end]) | |||
if err == nil { | |||
for _, tmp := range userList { | |||
userMap[tmp.ID] = tmp | |||
} | |||
} else { | |||
} | |||
end = end + 100 | |||
} | |||
row := 1 | |||
log.Info("len(userMap)=" + fmt.Sprint(len(userMap))) | |||
for _, userRecord := range invitaionNumList { | |||
row++ | |||
rows := fmt.Sprint(row) | |||
var tmp byte | |||
tmp = 0 | |||
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.SrcUserID) | |||
tmp = tmp + 1 | |||
name := "已注销" | |||
if userMap[userRecord.SrcUserID] != nil { | |||
name = userMap[userRecord.SrcUserID].Name | |||
} | |||
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, name) | |||
tmp = tmp + 1 | |||
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.InvitationUserNum) | |||
tmp = tmp + 1 | |||
Phone := "" | |||
if userMap[userRecord.SrcUserID] != nil { | |||
Phone = userMap[userRecord.SrcUserID].PhoneNumber | |||
} | |||
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, Phone) | |||
tmp = tmp + 1 | |||
formatTime := "" | |||
if userMap[userRecord.SrcUserID] != nil { | |||
formatTime = userMap[userRecord.SrcUserID].CreatedUnix.Format("2006-01-02 15:04:05") | |||
formatTime = formatTime[0 : len(formatTime)-3] | |||
} | |||
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime) | |||
} | |||
//设置默认打开的表单 | |||
xlsx.SetActiveSheet(index) | |||
filename := sheetName + "_" + getTimeFileName(startTime) + "_" + getTimeFileName(endTime) + ".xlsx" | |||
//filename := sheetName + "_" + ctx.Tr("user.static."+tableName) + ".xlsx" | |||
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) | |||
ctx.Resp.Header().Set("Content-Type", "application/octet-stream") | |||
if _, err := xlsx.WriteTo(ctx.Resp); err != nil { | |||
log.Info("writer exel error." + err.Error()) | |||
} | |||
} else { | |||
result := make([]*models.Invitation, 0) | |||
userIds := make([]int64, 0) | |||
end := len(invitaionNumList) - 1 | |||
for start := (page - 1) * pageSize; start <= end; start++ { | |||
invi := invitaionNumList[start] | |||
//todo name phone,createunix | |||
result = append(result, &invi) | |||
userIds = append(userIds, invi.SrcUserID) | |||
if len(result) == pageSize { | |||
break | |||
} | |||
} | |||
userList, err := models.GetUsersByIDs(userIds) | |||
if err == nil { | |||
for _, invi := range result { | |||
tmpUser := userList[0] | |||
for _, tmp := range userList { | |||
if tmp.ID == invi.SrcUserID { | |||
tmpUser = tmp | |||
break | |||
} | |||
} | |||
if invi.SrcUserID == tmpUser.ID { | |||
invi.Name = tmpUser.Name | |||
invi.Phone = tmpUser.PhoneNumber | |||
invi.CreatedUnix = tmpUser.CreatedUnix | |||
} else { | |||
invi.Name = "已注销" | |||
} | |||
} | |||
} else { | |||
log.Info("query user error." + err.Error()) | |||
} | |||
mapInterface := make(map[string]interface{}) | |||
mapInterface["data"] = result | |||
mapInterface["count"] = len(invitaionNumList) | |||
ctx.JSON(http.StatusOK, mapInterface) | |||
} | |||
} | |||
func getPageInfo(ctx *context.Context) (int, int) { | |||
page := ctx.QueryInt("page") | |||
@@ -48,9 +48,10 @@ | |||
</li> | |||
{{end}} | |||
{{end}} | |||
{{if and .IsSigned (eq .SignedUserName .Owner.Name)}} | |||
<li> | |||
{{svg "octicon-clock" 16}} {{.i18n.Tr "user.join_on"}} {{.Owner.CreatedUnix.FormatShort}} | |||
{{svg "octicon-clock" 16}} {{.i18n.Tr "user.join_on"}} {{.Owner.CreatedUnix.FormatShort}} | |||
{{if and .IsSigned (eq .SignedUserName .Owner.Name)}} | |||
<div class=__ad_profile_c__ style="margin-top:6px;height:50px;display:none;"> | |||
<a class="__ad_profile__" href="" target="_blank"><img src="" style="width:100%;height:100%" /></a> | |||
</div> | |||
@@ -78,9 +79,9 @@ | |||
}); | |||
})(); | |||
</script> | |||
{{end}} | |||
</li> | |||
{{end}} | |||
<li>{{svg "octicon-clock" 16}} {{.i18n.Tr "user.join_on"}} {{.Owner.CreatedUnix.FormatShort}}</li> | |||
{{if and .Orgs .HasOrgsVisible}} | |||
<li style="border-bottom: none;padding-bottom: 0;"><div style="border-bottom: 1px solid #eaeaea;padding-top: 5px;padding-bottom:5px"> <b>{{.i18n.Tr "organization"}} </b></div></li> | |||
@@ -166,7 +166,8 @@ const en = { | |||
inviteFriends: 'Invite Friends', | |||
inviteFriendsTips: 'Copy QR code or invite registration link to share with friends', | |||
clickToViewTheEventDetails: 'Click to view the event details', | |||
copyRegistrationInvitationLink: 'Copy registration invitation link', | |||
copyRegistrationInvitationLink: 'Copy registration invitation link', | |||
registrationAdress: 'Registration Adress: ', | |||
recommender: 'Recommender: ', | |||
invitedFriends: 'Invited friends', | |||
registrationTime: 'Registration time', | |||
@@ -164,9 +164,10 @@ const zh = { | |||
}, | |||
user: { | |||
inviteFriends: '邀请好友', | |||
inviteFriendsTips: '复制二维码或者邀请注册链接分享给好友', | |||
inviteFriendsTips: '复制二维码或者注册邀请链接分享给好友', | |||
clickToViewTheEventDetails: '点击查看活动详情', | |||
copyRegistrationInvitationLink: '复制注册邀请链接', | |||
registrationAdress: '注册地址:', | |||
recommender: '推荐人:', | |||
invitedFriends: '已邀请好友', | |||
registrationTime: '注册时间', | |||
@@ -19,7 +19,8 @@ | |||
<div class="txt-1"> | |||
<span>{{ pageOpeniDesc }}</span> | |||
</div> | |||
<div class="txt-2"><span>{{ invitationLink + invitationCode }}</span></div> | |||
<div class="txt-2"><span>{{ $t('user.registrationAdress') }}</span><span>{{ invitationLink + invitationCode | |||
}}</span></div> | |||
<div class="txt-3"><span>{{ $t('user.recommender') }}</span><span>{{ invitationCode }}</span></div> | |||
<el-button class="__copy_link_btn__" type="primary">{{ $t('user.copyRegistrationInvitationLink') }}</el-button> | |||
</div> | |||
@@ -46,8 +47,8 @@ | |||
<el-table-column prop="regTime" :label="$t('user.registrationTime')" align="center" header-align="center"> | |||
</el-table-column> | |||
<template slot="empty"> | |||
<span style="font-size: 12px">{{ | |||
loading ? $t('loading') : $t('noData') | |||
<span>{{ | |||
loading ? $t('loading') : $t('noData') | |||
}}</span> | |||
</template> | |||
</el-table> | |||
@@ -98,7 +99,7 @@ export default { | |||
initCopy() { | |||
const clipboard = new Clipboard('.__copy_link_btn__', { | |||
text: () => { | |||
return this.invitationLink + this.invitationCode; | |||
return `${this.pageOpeniDesc}\n${this.$t('user.registrationAdress')}${this.invitationLink + this.invitationCode}\n${this.$t('user.recommender')}${this.invitationCode}`; | |||
}, | |||
}); | |||
clipboard.on('success', (e) => { | |||
@@ -270,6 +271,13 @@ export default { | |||
} | |||
} | |||
.__copy_link_btn__ { | |||
font-size: 14px; | |||
padding: 11px 15px; | |||
background: rgb(21, 114, 255); | |||
border-radius: 0; | |||
} | |||
.qr-code { | |||
width: 150px; | |||
display: flex; | |||
@@ -284,14 +292,15 @@ export default { | |||
/deep/ .el-table__header { | |||
th { | |||
background: rgb(245, 245, 246); | |||
font-size: 12px; | |||
font-size: 14px; | |||
color: rgb(36, 36, 36); | |||
font-weight: 400; | |||
} | |||
} | |||
/deep/ .el-table__body { | |||
td { | |||
font-size: 12px; | |||
font-size: 14px; | |||
} | |||
} | |||