Browse Source

Merge branch 'V20220328' of git.openi.org.cn:OpenI/aiforge into cb-train

pull/1722/head
lewis 3 years ago
parent
commit
e077b78ed5
8 changed files with 120 additions and 63 deletions
  1. +15
    -0
      models/repo.go
  2. +39
    -37
      models/repo_statistic.go
  3. +5
    -0
      models/summary_statistic.go
  4. +3
    -0
      options/locale/locale_en-US.ini
  5. +3
    -0
      options/locale/locale_zh-CN.ini
  6. +27
    -26
      routers/api/v1/repo/repo_dashbord.go
  7. +2
    -0
      routers/repo/repo_statistic.go
  8. +26
    -0
      routers/repo/repo_summary_statistic.go

+ 15
- 0
models/repo.go View File

@@ -1547,6 +1547,21 @@ func GetAllRepositoriesCount() (int64, error) {
return x.Count(repo) return x.Count(repo)
} }


func GetAllPublicRepositoriesCount() (int64, error) {
repo := new(Repository)
return x.Where("is_private = ?", false).Count(repo)
}

func GetAllMirrorRepositoriesCount() (int64, error) {
repo := new(Repository)
return x.Where("is_mirror = ?", true).Count(repo)
}

func GetAllForkRepositoriesCount() (int64, error) {
repo := new(Repository)
return x.Where("is_fork = ?", true).Count(repo)
}

func GetAllRepositoriesSize() (int64, error) { func GetAllRepositoriesSize() (int64, error) {
return x.SumInt(&Repository{}, "size") return x.SumInt(&Repository{}, "size")
} }


+ 39
- 37
models/repo_statistic.go View File

@@ -9,43 +9,45 @@ import (


// RepoStatistic statistic info of all repository // RepoStatistic statistic info of all repository
type RepoStatistic struct { type RepoStatistic struct {
ID int64 `xorm:"pk autoincr" json:"-"`
RepoID int64 `xorm:"unique(s) NOT NULL" json:"repo_id"`
Name string `xorm:"INDEX" json:"name"`
Alias string `xorm:"INDEX" json:"alias"`
OwnerName string `json:"ownerName"`
IsPrivate bool `json:"isPrivate"`
IsMirror bool `json:"isMirror"`
Date string `xorm:"unique(s) NOT NULL" json:"date"`
NumWatches int64 `xorm:"NOT NULL DEFAULT 0" json:"watch"`
NumWatchesAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumStars int64 `xorm:"NOT NULL DEFAULT 0" json:"star"`
NumStarsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumForks int64 `xorm:"NOT NULL DEFAULT 0" json:"fork"`
NumForksAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumDownloads int64 `xorm:"NOT NULL DEFAULT 0" json:"download"`
NumDownloadsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumComments int64 `xorm:"NOT NULL DEFAULT 0" json:"comment"`
NumCommentsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumVisits int64 `xorm:"NOT NULL DEFAULT 0" json:"view"`
NumClosedIssues int64 `xorm:"NOT NULL DEFAULT 0" json:"issueClosed"`
NumClosedIssuesAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumVersions int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumDevMonths int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
RepoSize int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
DatasetSize int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumModels int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumWikiViews int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumCommits int64 `xorm:"NOT NULL DEFAULT 0" json:"commit"`
NumCommitsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumIssues int64 `xorm:"NOT NULL DEFAULT 0" json:"issue"`
NumIssuesAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumPulls int64 `xorm:"NOT NULL DEFAULT 0" json:"pr"`
NumPullsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
IssueFixedRate float32 `xorm:"NOT NULL" json:"issueClosedRatio"`
NumContributor int64 `xorm:"NOT NULL DEFAULT 0" json:"contributor"`
NumContributorAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumKeyContributor int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
ID int64 `xorm:"pk autoincr" json:"-"`
RepoID int64 `xorm:"unique(s) NOT NULL" json:"repo_id"`
Name string `xorm:"INDEX" json:"name"`
Alias string `xorm:"INDEX" json:"alias"`
OwnerName string `json:"ownerName"`
IsPrivate bool `json:"isPrivate"`
IsMirror bool `json:"isMirror"`
IsFork bool `json:"isFork"`
RepoCreatedUnix timeutil.TimeStamp `xorm:"NOT NULL" json:"createUnix"`
Date string `xorm:"unique(s) NOT NULL" json:"date"`
NumWatches int64 `xorm:"NOT NULL DEFAULT 0" json:"watch"`
NumWatchesAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumStars int64 `xorm:"NOT NULL DEFAULT 0" json:"star"`
NumStarsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumForks int64 `xorm:"NOT NULL DEFAULT 0" json:"fork"`
NumForksAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumDownloads int64 `xorm:"NOT NULL DEFAULT 0" json:"download"`
NumDownloadsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumComments int64 `xorm:"NOT NULL DEFAULT 0" json:"comment"`
NumCommentsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumVisits int64 `xorm:"NOT NULL DEFAULT 0" json:"view"`
NumClosedIssues int64 `xorm:"NOT NULL DEFAULT 0" json:"issueClosed"`
NumClosedIssuesAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumVersions int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumDevMonths int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
RepoSize int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
DatasetSize int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumModels int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumWikiViews int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumCommits int64 `xorm:"NOT NULL DEFAULT 0" json:"commit"`
NumCommitsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumIssues int64 `xorm:"NOT NULL DEFAULT 0" json:"issue"`
NumIssuesAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumPulls int64 `xorm:"NOT NULL DEFAULT 0" json:"pr"`
NumPullsAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
IssueFixedRate float32 `xorm:"NOT NULL" json:"issueClosedRatio"`
NumContributor int64 `xorm:"NOT NULL DEFAULT 0" json:"contributor"`
NumContributorAdded int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumKeyContributor int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`


NumContributorsGrowth int64 `xorm:"NOT NULL DEFAULT 0" json:"-"` NumContributorsGrowth int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`
NumCommitsGrowth int64 `xorm:"NOT NULL DEFAULT 0" json:"-"` NumCommitsGrowth int64 `xorm:"NOT NULL DEFAULT 0" json:"-"`


+ 5
- 0
models/summary_statistic.go View File

@@ -40,6 +40,11 @@ type SummaryStatistic struct {
NumRepoLeagueLearn int `xorm:"NOT NULL DEFAULT 0"` NumRepoLeagueLearn int `xorm:"NOT NULL DEFAULT 0"`
NumRepoDataMining int `xorm:"NOT NULL DEFAULT 0"` NumRepoDataMining int `xorm:"NOT NULL DEFAULT 0"`
NumRepoRISC int `xorm:"NOT NULL DEFAULT 0"` NumRepoRISC int `xorm:"NOT NULL DEFAULT 0"`
NumRepoPublic int64 `xorm:"NOT NULL DEFAULT 0"`
NumRepoPrivate int64 `xorm:"NOT NULL DEFAULT 0"`
NumRepoFork int64 `xorm:"NOT NULL DEFAULT 0"`
NumRepoMirror int64 `xorm:"NOT NULL DEFAULT 0"`
NumRepoSelf int64 `xorm:"NOT NULL DEFAULT 0"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
} }


+ 3
- 0
options/locale/locale_en-US.ini View File

@@ -2348,6 +2348,9 @@ repos.size = Size
repos.id=ID repos.id=ID
repos.projectName=Project Name repos.projectName=Project Name
repos.isPrivate=Private repos.isPrivate=Private
repos.create=Project Create Time
repos.isFork=Fork
repos.isMirror=Mirror
repos.openi=OpenI repos.openi=OpenI
repos.visit=Visit repos.visit=Visit
repos.download=Code Download repos.download=Code Download


+ 3
- 0
options/locale/locale_zh-CN.ini View File

@@ -2356,6 +2356,9 @@ repos.size=大小
repos.id=ID repos.id=ID
repos.projectName=项目名称 repos.projectName=项目名称
repos.isPrivate=私有 repos.isPrivate=私有
repos.create=项目创建时间
repos.isFork=派生
repos.isMirror=镜像
repos.openi=OpenI指数 repos.openi=OpenI指数
repos.visit=浏览量 repos.visit=浏览量
repos.download=代码下载量 repos.download=代码下载量


+ 27
- 26
routers/api/v1/repo/repo_dashbord.go View File

@@ -21,6 +21,7 @@ import (
const DEFAULT_PAGE_SIZE = 10 const DEFAULT_PAGE_SIZE = 10
const DATE_FORMAT = "2006-01-02" const DATE_FORMAT = "2006-01-02"
const EXCEL_DATE_FORMAT = "20060102" const EXCEL_DATE_FORMAT = "20060102"
const CREATE_TIME_FORMAT = "2006/01/02 15:04:05"


type ProjectsPeriodData struct { type ProjectsPeriodData struct {
RecordBeginTime string `json:"recordBeginTime"` RecordBeginTime string `json:"recordBeginTime"`
@@ -291,41 +292,41 @@ func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, p


func allProjectsPeroidHeader(ctx *context.Context) map[string]string { func allProjectsPeroidHeader(ctx *context.Context) map[string]string {


return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("repo.owner"), "D1": ctx.Tr("admin.repos.isPrivate"), "E1": ctx.Tr("admin.repos.openi"), "F1": ctx.Tr("admin.repos.visit"), "G1": ctx.Tr("admin.repos.download"), "H1": ctx.Tr("admin.repos.pr"), "I1": ctx.Tr("admin.repos.commit"),
"J1": ctx.Tr("admin.repos.watches"), "K1": ctx.Tr("admin.repos.stars"), "L1": ctx.Tr("admin.repos.forks"), "M1": ctx.Tr("admin.repos.issues"), "N1": ctx.Tr("admin.repos.closedIssues"), "O1": ctx.Tr("admin.repos.contributor")}
return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("repo.owner"), "D1": ctx.Tr("admin.repos.isPrivate"), "E1": ctx.Tr("admin.repos.isFork"), "F1": ctx.Tr("admin.repos.isMirror"), "G1": ctx.Tr("admin.repos.openi"), "H1": ctx.Tr("admin.repos.visit"), "I1": ctx.Tr("admin.repos.download"), "J1": ctx.Tr("admin.repos.pr"), "K1": ctx.Tr("admin.repos.commit"),
"L1": ctx.Tr("admin.repos.watches"), "M1": ctx.Tr("admin.repos.stars"), "N1": ctx.Tr("admin.repos.forks"), "O1": ctx.Tr("admin.repos.issues"), "P1": ctx.Tr("admin.repos.closedIssues"), "Q1": ctx.Tr("admin.repos.contributor"), "R1": ctx.Tr("admin.repos.create")}


} }


func allProjectsPeroidValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { func allProjectsPeroidValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string {
return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64),
getCellName("F", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("G", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("H", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("I", row): strconv.FormatInt(rs.NumCommits, 10),
getCellName("J", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("K", row): strconv.FormatInt(rs.NumStars, 10), getCellName("L", row): strconv.FormatInt(rs.NumForks, 10), getCellName("M", row): strconv.FormatInt(rs.NumIssues, 10),
getCellName("N", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("O", row): strconv.FormatInt(rs.NumContributor, 10),
return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): getBoolDisplay(rs.IsFork, ctx), getCellName("F", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("G", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64),
getCellName("H", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("I", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("J", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("K", row): strconv.FormatInt(rs.NumCommits, 10),
getCellName("L", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("M", row): strconv.FormatInt(rs.NumStars, 10), getCellName("N", row): strconv.FormatInt(rs.NumForks, 10), getCellName("O", row): strconv.FormatInt(rs.NumIssues, 10),
getCellName("P", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("Q", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("R", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT),
} }
} }


func allProjectsOpenIHeader() map[string]string { func allProjectsOpenIHeader() map[string]string {


return map[string]string{"A1": "ID", "B1": "项目名称", "C1": "拥有者", "D1": "是否私有", "E1": "OpenI指数",
"F1": "影响力", "G1": "成熟度", "H1": "活跃度", "I1": "项目健康度", "J1": "团队健康度", "K1": "项目发展趋势",
"L1": "关注数", "M1": "点赞数", "N1": "派生数", "O1": "代码下载量", "P1": "评论数", "Q1": "浏览量", "R1": "已解决任务数", "S1": "版本发布数量", "T1": "有效开发年龄",
"U1": "数据集", "V1": "模型数", "W1": "百科页面数量", "X1": "提交数", "Y1": "任务数", "Z1": "PR数", "AA1": "版本发布数量", "AB1": "任务完成比例", "AC1": "贡献者数", "AD1": "关键贡献者数",
"AE1": "新人增长量", "AF1": "代码规模增长量", "AG1": "任务增长量", "AH1": "新人增长量", "AI1": "提交增长量", "AJ1": "评论增长量",
return map[string]string{"A1": "ID", "B1": "项目名称", "C1": "拥有者", "D1": "私有", "E1": "迁移", "F1": "镜像", "G1": "OpenI指数",
"H1": "影响力", "I1": "成熟度", "J1": "活跃度", "K1": "项目健康度", "L1": "团队健康度", "M1": "项目发展趋势",
"N1": "关注数", "O1": "点赞数", "P1": "派生数", "Q1": "代码下载量", "R1": "评论数", "S1": "浏览量", "T1": "已解决任务数", "U1": "版本发布数量", "V1": "有效开发年龄",
"W1": "数据集", "X1": "模型数", "Y1": "百科页面数量", "Z1": "提交数", "AA1": "任务数", "AB1": "PR数", "AC1": "版本发布数量", "AD1": "任务完成比例", "AE1": "贡献者数", "AF1": "关键贡献者数",
"AG1": "新人增长量", "AH1": "代码规模增长量", "AI1": "任务增长量", "AJ1": "新人增长量", "AK1": "提交增长量", "AL1": "评论增长量", "AM1": "项目创建时间",
} }


} }


func allProjectsOpenIValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { func allProjectsOpenIValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string {


return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64),
getCellName("F", row): strconv.FormatFloat(rs.Impact, 'f', 2, 64), getCellName("G", row): strconv.FormatFloat(rs.Completeness, 'f', 2, 64), getCellName("H", row): strconv.FormatFloat(rs.Liveness, 'f', 2, 64), getCellName("I", row): strconv.FormatFloat(rs.ProjectHealth, 'f', 2, 64), getCellName("J", row): strconv.FormatFloat(rs.TeamHealth, 'f', 2, 64), getCellName("K", row): strconv.FormatFloat(rs.Growth, 'f', 2, 64),
getCellName("L", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("M", row): strconv.FormatInt(rs.NumStars, 10), getCellName("N", row): strconv.FormatInt(rs.NumForks, 10), getCellName("O", row): strconv.FormatInt(rs.NumDownloads, 10),
return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): getBoolDisplay(rs.IsFork, ctx), getCellName("F", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("G", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64),
getCellName("H", row): strconv.FormatFloat(rs.Impact, 'f', 2, 64), getCellName("I", row): strconv.FormatFloat(rs.Completeness, 'f', 2, 64), getCellName("J", row): strconv.FormatFloat(rs.Liveness, 'f', 2, 64), getCellName("K", row): strconv.FormatFloat(rs.ProjectHealth, 'f', 2, 64), getCellName("L", row): strconv.FormatFloat(rs.TeamHealth, 'f', 2, 64), getCellName("M", row): strconv.FormatFloat(rs.Growth, 'f', 2, 64),
getCellName("N", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("O", row): strconv.FormatInt(rs.NumStars, 10), getCellName("P", row): strconv.FormatInt(rs.NumForks, 10), getCellName("Q", row): strconv.FormatInt(rs.NumDownloads, 10),


getCellName("P", row): strconv.FormatInt(rs.NumComments, 10), getCellName("Q", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("R", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("S", row): strconv.FormatInt(rs.NumVersions, 10),
getCellName("T", row): strconv.FormatInt(rs.NumDevMonths, 10), getCellName("U", row): strconv.FormatInt(rs.DatasetSize, 10), getCellName("V", row): strconv.FormatInt(rs.NumModels, 10), getCellName("W", row): strconv.FormatInt(rs.NumWikiViews, 10),
getCellName("X", row): strconv.FormatInt(rs.NumCommits, 10), getCellName("Y", row): strconv.FormatInt(rs.NumIssues, 10), getCellName("Z", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("AA", row): strconv.FormatInt(rs.NumVersions, 10),
getCellName("AB", row): strconv.FormatFloat(float64(rs.IssueFixedRate), 'f', 2, 64), getCellName("AC", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("AD", row): strconv.FormatInt(rs.NumKeyContributor, 10), getCellName("AE", row): strconv.FormatInt(rs.NumContributorsGrowth, 10),
getCellName("AF", row): strconv.FormatInt(rs.NumCommitLinesGrowth, 10), getCellName("AG", row): strconv.FormatInt(rs.NumIssuesGrowth, 10), getCellName("AH", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), getCellName("AI", row): strconv.FormatInt(rs.NumCommitsGrowth, 10), getCellName("AJ", row): strconv.FormatInt(rs.NumCommentsGrowth, 10),
getCellName("R", row): strconv.FormatInt(rs.NumComments, 10), getCellName("S", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("T", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("U", row): strconv.FormatInt(rs.NumVersions, 10),
getCellName("V", row): strconv.FormatInt(rs.NumDevMonths, 10), getCellName("W", row): strconv.FormatInt(rs.DatasetSize, 10), getCellName("X", row): strconv.FormatInt(rs.NumModels, 10), getCellName("Y", row): strconv.FormatInt(rs.NumWikiViews, 10),
getCellName("Z", row): strconv.FormatInt(rs.NumCommits, 10), getCellName("AA", row): strconv.FormatInt(rs.NumIssues, 10), getCellName("AB", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("AC", row): strconv.FormatInt(rs.NumVersions, 10),
getCellName("AD", row): strconv.FormatFloat(float64(rs.IssueFixedRate), 'f', 2, 64), getCellName("AE", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("AF", row): strconv.FormatInt(rs.NumKeyContributor, 10), getCellName("AG", row): strconv.FormatInt(rs.NumContributorsGrowth, 10),
getCellName("AH", row): strconv.FormatInt(rs.NumCommitLinesGrowth, 10), getCellName("AI", row): strconv.FormatInt(rs.NumIssuesGrowth, 10), getCellName("AJ", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), getCellName("AK", row): strconv.FormatInt(rs.NumCommitsGrowth, 10), getCellName("AL", row): strconv.FormatInt(rs.NumCommentsGrowth, 10), getCellName("AM", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT),
} }


} }
@@ -334,8 +335,8 @@ func getCellName(col string, row int) string {
return col + strconv.Itoa(row) return col + strconv.Itoa(row)
} }


func getIsPrivateDisplay(private bool, ctx *context.Context) string {
if private {
func getBoolDisplay(value bool, ctx *context.Context) string {
if value {
return ctx.Tr("admin.repos.yes") return ctx.Tr("admin.repos.yes")
} else { } else {
return ctx.Tr("admin.repos.no") return ctx.Tr("admin.repos.no")
@@ -482,11 +483,11 @@ func generateOpenICountSql(latestDate string) string {
} }


func generateTypeAllSql(beginTime time.Time, endTime time.Time, latestDate string, q string, orderBy string, page int, pageSize int) string { func generateTypeAllSql(beginTime time.Time, endTime time.Time, latestDate string, q string, orderBy string, page int, pageSize int) string {
sql := "SELECT A.repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " +
sql := "SELECT A.repo_id,name,alias,owner_name,is_private,is_mirror,is_fork,repo_created_unix,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " +
"(SELECT repo_id,sum(num_visits) as num_visits " + "(SELECT repo_id,sum(num_visits) as num_visits " +
" FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + " FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," + " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," +
"(SELECT repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor from public.repo_statistic where date='" + latestDate + "') B" +
"(SELECT repo_id,name,alias,owner_name,is_private,is_mirror,is_fork,repo_created_unix,radar_total,num_watches,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor from public.repo_statistic where date='" + latestDate + "') B" +
" where A.repo_id=B.repo_id" " where A.repo_id=B.repo_id"


if q != "" { if q != "" {
@@ -497,7 +498,7 @@ func generateTypeAllSql(beginTime time.Time, endTime time.Time, latestDate strin
} }


func generateTypeAllOpenISql(latestDate string, page int, pageSize int) string { func generateTypeAllOpenISql(latestDate string, page int, pageSize int) string {
sql := "SELECT id, repo_id, date, num_watches, num_stars, num_forks, num_downloads, num_comments, num_visits, num_closed_issues, num_versions, num_dev_months, repo_size, dataset_size, num_models, num_wiki_views, num_commits, num_issues, num_pulls, issue_fixed_rate, num_contributor, num_key_contributor, num_contributors_growth, num_commits_growth, num_commit_lines_growth, num_issues_growth, num_comments_growth, impact, completeness, liveness, project_health, team_health, growth, radar_total, name,alias, is_private, owner_name FROM " +
sql := "SELECT id, repo_id, date, num_watches, num_stars, num_forks, num_downloads, num_comments, num_visits, num_closed_issues, num_versions, num_dev_months, repo_size, dataset_size, num_models, num_wiki_views, num_commits, num_issues, num_pulls, issue_fixed_rate, num_contributor, num_key_contributor, num_contributors_growth, num_commits_growth, num_commit_lines_growth, num_issues_growth, num_comments_growth, impact, completeness, liveness, project_health, team_health, growth, radar_total, name,alias, is_private,is_mirror,is_fork,repo_created_unix, owner_name FROM " +
" public.repo_statistic where date='" + latestDate + "'" " public.repo_statistic where date='" + latestDate + "'"


sql = sql + " order by radar_total desc,repo_id" + " limit " + strconv.Itoa(pageSize) + " offset " + strconv.Itoa((page-1)*pageSize) sql = sql + " order by radar_total desc,repo_id" + " limit " + strconv.Itoa(pageSize) + " offset " + strconv.Itoa((page-1)*pageSize)
@@ -506,11 +507,11 @@ func generateTypeAllOpenISql(latestDate string, page int, pageSize int) string {


func generatePageSql(beginTime time.Time, endTime time.Time, latestDate string, q string, orderBy string, page int, pageSize int) string { func generatePageSql(beginTime time.Time, endTime time.Time, latestDate string, q string, orderBy string, page int, pageSize int) string {


sql := "SELECT A.repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " +
sql := "SELECT A.repo_id,name,alias,owner_name,is_private,is_mirror,is_fork,repo_created_unix,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " +
"(SELECT repo_id,sum(num_watches_added) as num_watches,sum(num_visits) as num_visits, sum(num_downloads_added) as num_downloads,sum(num_pulls_added) as num_pulls,sum(num_commits_added) as num_commits,sum(num_stars_added) as num_stars,sum(num_forks_added) num_forks,sum(num_issues_added) as num_issues,sum(num_closed_issues_added) as num_closed_issues,sum(num_contributor_added) as num_contributor " + "(SELECT repo_id,sum(num_watches_added) as num_watches,sum(num_visits) as num_visits, sum(num_downloads_added) as num_downloads,sum(num_pulls_added) as num_pulls,sum(num_commits_added) as num_commits,sum(num_stars_added) as num_stars,sum(num_forks_added) num_forks,sum(num_issues_added) as num_issues,sum(num_closed_issues_added) as num_closed_issues,sum(num_contributor_added) as num_contributor " +
" FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + " FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," + " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," +
"(SELECT repo_id,name,alias,owner_name,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" +
"(SELECT repo_id,name,alias,owner_name,is_private,is_mirror,is_fork,repo_created_unix,radar_total from public.repo_statistic where date='" + latestDate + "') B" +
" where A.repo_id=B.repo_id" " where A.repo_id=B.repo_id"
if q != "" { if q != "" {
sql = sql + " and LOWER(B.alias) like '%" + strings.ToLower(q) + "%'" sql = sql + " and LOWER(B.alias) like '%" + strings.ToLower(q) + "%'"


+ 2
- 0
routers/repo/repo_statistic.go View File

@@ -110,6 +110,8 @@ func RepoStatisticDaily(date string) {
Alias: repo.Alias, Alias: repo.Alias,
IsPrivate: repo.IsPrivate, IsPrivate: repo.IsPrivate,
IsMirror: repo.IsMirror, IsMirror: repo.IsMirror,
IsFork: repo.IsFork,
RepoCreatedUnix: repo.CreatedUnix,
OwnerName: repo.OwnerName, OwnerName: repo.OwnerName,
NumWatches: int64(repo.NumWatches), NumWatches: int64(repo.NumWatches),
NumStars: int64(repo.NumStars), NumStars: int64(repo.NumStars),


+ 26
- 0
routers/repo/repo_summary_statistic.go View File

@@ -39,6 +39,27 @@ func SummaryStatisticDaily(date string) {
log.Error("can not get repository number", err) log.Error("can not get repository number", err)
repositoryNumer = 0 repositoryNumer = 0
} }

publicRepositoryNumer, err := models.GetAllPublicRepositoriesCount()
if err != nil {
log.Error("can not get public repository number", err)
publicRepositoryNumer = 0
}

privateRepositoryNumer := repositoryNumer - publicRepositoryNumer

mirrorRepositoryNumber, err := models.GetAllMirrorRepositoriesCount()
if err != nil {
log.Error("can not get mirror repository number", err)
mirrorRepositoryNumber = 0
}
forkRepositoryNumber, err := models.GetAllForkRepositoriesCount()
if err != nil {
log.Error("can not get fork mirror repository number", err)
forkRepositoryNumber = 0
}
selfRepositoryNumber := repositoryNumer - mirrorRepositoryNumber - forkRepositoryNumber

//repository size //repository size
repositorySize, err := models.GetAllRepositoriesSize() repositorySize, err := models.GetAllRepositoriesSize()
if err != nil { if err != nil {
@@ -73,6 +94,11 @@ func SummaryStatisticDaily(date string) {
DatasetSize: allDatasetSize, DatasetSize: allDatasetSize,
NumOrganizations: organizationNumber, NumOrganizations: organizationNumber,
NumRepos: repositoryNumer, NumRepos: repositoryNumer,
NumRepoFork: forkRepositoryNumber,
NumRepoMirror: mirrorRepositoryNumber,
NumRepoPrivate: privateRepositoryNumer,
NumRepoPublic: publicRepositoryNumer,
NumRepoSelf: selfRepositoryNumber,
NumRepoBigModel: topicsCount[0], NumRepoBigModel: topicsCount[0],
NumRepoAI: topicsCount[1], NumRepoAI: topicsCount[1],
NumRepoVision: topicsCount[2], NumRepoVision: topicsCount[2],


Loading…
Cancel
Save