Browse Source

Merge branch 'V20211101' into fix-472

pull/600/head
zhoupzh 3 years ago
parent
commit
7144981d77
6 changed files with 31 additions and 27 deletions
  1. +2
    -0
      modules/context/context.go
  2. BIN
      public/img/org-jd@2x-80.jpg
  3. +1
    -1
      routers/home.go
  4. +23
    -22
      routers/repo/repo_statistic.go
  5. +4
    -3
      routers/routes/routes.go
  6. +1
    -1
      templates/repo/datasets/dataset_list.tmpl

+ 2
- 0
modules/context/context.go View File

@@ -310,9 +310,11 @@ func Contexter() macaron.Handler {
ctx.Data["SignedUserID"] = ctx.User.ID
ctx.Data["SignedUserName"] = ctx.User.Name
ctx.Data["IsAdmin"] = ctx.User.IsAdmin
c.Data["SignedUserName"] = ctx.User.Name
} else {
ctx.Data["SignedUserID"] = int64(0)
ctx.Data["SignedUserName"] = ""
c.Data["SignedUserName"] = ""
}

// If request sends files, parse them here otherwise the Query() can't be parsed and the CsrfToken will be invalid.


BIN
public/img/org-jd@2x-80.jpg View File

Before After
Width: 401  |  Height: 121  |  Size: 33 kB Width: 201  |  Height: 80  |  Size: 6.5 kB

+ 1
- 1
routers/home.go View File

@@ -281,10 +281,10 @@ func ExploreDatasets(ctx *context.Context) {
}

pager := context.NewPagination(int(count), opts.PageSize, page, 5)
ctx.Data["Keyword"] = opts.Keyword
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager

ctx.Data["Keyword"] = opts.Keyword
ctx.Data["Datasets"] = datasets
ctx.Data["Total"] = count
ctx.Data["PageIsDatasets"] = true


+ 23
- 22
routers/repo/repo_statistic.go View File

@@ -30,11 +30,15 @@ func RepoStatisticDaily(date string) {

for _, repo := range repos {
log.Info("start statistic: %s", repo.Name)
var numDevMonths,numWikiViews,numContributor,numKeyContributor int64
repoGitStat, err := models.GetRepoKPIStats(repo)
if err != nil {
log.Error("GetRepoKPIStats failed: %s", repo.Name)
log.Error("failed statistic: %s", repo.Name)
continue
} else {
numDevMonths = repoGitStat.DevelopAge
numKeyContributor = repoGitStat.KeyContributors
numWikiViews = repoGitStat.WikiPages
numContributor = repoGitStat.Contributors
}

var issueFixedRate float32
@@ -42,32 +46,29 @@ func RepoStatisticDaily(date string) {
issueFixedRate = float32(repo.NumClosedIssues) / float32(repo.NumIssues)
}

numVersions, err := models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{})
var numVersions int64
numVersions, err = models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{})
if err != nil {
log.Error("GetReleaseCountByRepoID failed: %s", repo.Name)
log.Error("failed statistic: %s", repo.Name)
continue
log.Error("GetReleaseCountByRepoID failed(%s): %v", repo.Name, err)
}

datasetSize, err := getDatasetSize(repo)
var datasetSize int64
datasetSize, err = getDatasetSize(repo)
if err != nil {
log.Error("getDatasetSize failed: %s", repo.Name)
log.Error("failed statistic: %s", repo.Name)
continue
log.Error("getDatasetSize failed(%s): %v", repo.Name, err)
}

numComments, err := models.GetCommentCountByRepoID(repo.ID)
var numComments int64
numComments, err = models.GetCommentCountByRepoID(repo.ID)
if err != nil {
log.Error("GetCommentCountByRepoID failed: %s", repo.Name)
log.Error("failed statistic: %s", repo.Name)
continue
log.Error("GetCommentCountByRepoID failed(%s): %v", repo.Name, err)
}

beginTime, endTime := getStatTime(date)
numVisits, err := repository.AppointProjectView(repo.OwnerName, repo.Name, beginTime, endTime)
var numVisits int
numVisits, err = repository.AppointProjectView(repo.OwnerName, repo.Name, beginTime, endTime)
if err != nil {
log.Error("Get numVisits failed", err)
numVisits = 0
log.Error("AppointProjectView failed(%s): %v", repo.Name, err)
}

repoStat := models.RepoStatistic{
@@ -80,21 +81,21 @@ func RepoStatisticDaily(date string) {
NumVisits: int64(numVisits),
NumClosedIssues: int64(repo.NumClosedIssues),
NumVersions: numVersions,
NumDevMonths: repoGitStat.DevelopAge,
NumDevMonths: numDevMonths,
RepoSize: repo.Size,
DatasetSize: datasetSize,
NumModels: 0,
NumWikiViews: repoGitStat.WikiPages,
NumWikiViews: numWikiViews,
NumCommits: repo.NumCommit,
NumIssues: int64(repo.NumIssues),
NumPulls: int64(repo.NumPulls),
IssueFixedRate: issueFixedRate,
NumContributor: repoGitStat.Contributors,
NumKeyContributor: repoGitStat.KeyContributors,
NumContributor: numContributor,
NumKeyContributor: numKeyContributor,
}

if _, err = models.InsertRepoStat(&repoStat); err != nil {
log.Error("InsertRepoStat failed: %s", repo.Name)
log.Error("InsertRepoStat failed(%s): %v", repo.Name, err)
log.Error("failed statistic: %s", repo.Name)
continue
}


+ 4
- 3
routers/routes/routes.go View File

@@ -114,14 +114,14 @@ func RouterHandler(level log.Level) func(ctx *macaron.Context) {
}

// SetLogMsgID set msgID in Context
func SetLogMsgID() func(ctx *macaron.Context) {
func SetLogMsgID() macaron.Handler {
return func(ctx *macaron.Context) {
start := time.Now()

uuid := gouuid.NewV4().String()
ctx.Data["MsgID"] = uuid

log.Info("Started %s %s for %s", log.ColoredMethod(ctx.Req.Method), ctx.Req.URL.RequestURI(), ctx.RemoteAddr(), ctx.Data["MsgID"])
log.Info("%s Started %s %s for %s", ctx.Data["SignedUserName"], log.ColoredMethod(ctx.Req.Method), ctx.Req.URL.RequestURI(), ctx.RemoteAddr(), ctx.Data["MsgID"])

rw := ctx.Resp.(macaron.ResponseWriter)
ctx.Next()
@@ -149,7 +149,7 @@ func NewMacaron() *macaron.Macaron {
m.Use(macaron.Logger())
}
}
m.Use(SetLogMsgID())
//m.Use(SetLogMsgID())
// Access Logger is similar to Router Log but more configurable and by default is more like the NCSA Common Log format
if setting.EnableAccessLog {
setupAccessLogger(m)
@@ -257,6 +257,7 @@ func NewMacaron() *macaron.Macaron {
DisableDebug: !setting.EnablePprof,
}))
m.Use(context.Contexter())
m.Use(SetLogMsgID())
// OK we are now set-up enough to allow us to create a nicer recovery than
// the default macaron recovery
m.Use(context.Recovery())


+ 1
- 1
templates/repo/datasets/dataset_list.tmpl View File

@@ -17,7 +17,7 @@
<span class="ui basic basic button clipboard" data-clipboard-text="{{.DownloadURL}}" data-tooltip='{{$.i18n.Tr "dataset.copy_url"}}' data-clipboard-action="copy"{{if ne $.Type 0}} style="display:none;"{{end}}>{{svg "octicon-file" 16}}</span>
<span class="ui basic basic button clipboard" data-clipboard-text="{{.FileChunk.Md5}}" data-tooltip='{{$.i18n.Tr "dataset.copy_md5"}}' data-clipboard-action="copy">{{svg "octicon-file-binary" 16}}</span>
</div>
{{if ne .DecompressState 0}}
{{if eq .DecompressState 1}}
<div class="ui left mini icon buttons">
<a class="ui basic blue button" href="datasets/dirs/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.directory"}}'>{{svg "octicon-file-directory" 16}}</a>
{{if $.IsSigned}}


Loading…
Cancel
Save