| @@ -310,9 +310,11 @@ func Contexter() macaron.Handler { | |||||
| ctx.Data["SignedUserID"] = ctx.User.ID | ctx.Data["SignedUserID"] = ctx.User.ID | ||||
| ctx.Data["SignedUserName"] = ctx.User.Name | ctx.Data["SignedUserName"] = ctx.User.Name | ||||
| ctx.Data["IsAdmin"] = ctx.User.IsAdmin | ctx.Data["IsAdmin"] = ctx.User.IsAdmin | ||||
| c.Data["SignedUserName"] = ctx.User.Name | |||||
| } else { | } else { | ||||
| ctx.Data["SignedUserID"] = int64(0) | ctx.Data["SignedUserID"] = int64(0) | ||||
| ctx.Data["SignedUserName"] = "" | 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. | // If request sends files, parse them here otherwise the Query() can't be parsed and the CsrfToken will be invalid. | ||||
| @@ -281,10 +281,10 @@ func ExploreDatasets(ctx *context.Context) { | |||||
| } | } | ||||
| pager := context.NewPagination(int(count), opts.PageSize, page, 5) | pager := context.NewPagination(int(count), opts.PageSize, page, 5) | ||||
| ctx.Data["Keyword"] = opts.Keyword | |||||
| pager.SetDefaultParams(ctx) | pager.SetDefaultParams(ctx) | ||||
| ctx.Data["Page"] = pager | ctx.Data["Page"] = pager | ||||
| ctx.Data["Keyword"] = opts.Keyword | |||||
| ctx.Data["Datasets"] = datasets | ctx.Data["Datasets"] = datasets | ||||
| ctx.Data["Total"] = count | ctx.Data["Total"] = count | ||||
| ctx.Data["PageIsDatasets"] = true | ctx.Data["PageIsDatasets"] = true | ||||
| @@ -30,11 +30,15 @@ func RepoStatisticDaily(date string) { | |||||
| for _, repo := range repos { | for _, repo := range repos { | ||||
| log.Info("start statistic: %s", repo.Name) | log.Info("start statistic: %s", repo.Name) | ||||
| var numDevMonths,numWikiViews,numContributor,numKeyContributor int64 | |||||
| repoGitStat, err := models.GetRepoKPIStats(repo) | repoGitStat, err := models.GetRepoKPIStats(repo) | ||||
| if err != nil { | if err != nil { | ||||
| log.Error("GetRepoKPIStats failed: %s", repo.Name) | 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 | var issueFixedRate float32 | ||||
| @@ -42,32 +46,29 @@ func RepoStatisticDaily(date string) { | |||||
| issueFixedRate = float32(repo.NumClosedIssues) / float32(repo.NumIssues) | 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 { | 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 { | 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 { | 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) | 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 { | if err != nil { | ||||
| log.Error("Get numVisits failed", err) | |||||
| numVisits = 0 | |||||
| log.Error("AppointProjectView failed(%s): %v", repo.Name, err) | |||||
| } | } | ||||
| repoStat := models.RepoStatistic{ | repoStat := models.RepoStatistic{ | ||||
| @@ -80,21 +81,21 @@ func RepoStatisticDaily(date string) { | |||||
| NumVisits: int64(numVisits), | NumVisits: int64(numVisits), | ||||
| NumClosedIssues: int64(repo.NumClosedIssues), | NumClosedIssues: int64(repo.NumClosedIssues), | ||||
| NumVersions: numVersions, | NumVersions: numVersions, | ||||
| NumDevMonths: repoGitStat.DevelopAge, | |||||
| NumDevMonths: numDevMonths, | |||||
| RepoSize: repo.Size, | RepoSize: repo.Size, | ||||
| DatasetSize: datasetSize, | DatasetSize: datasetSize, | ||||
| NumModels: 0, | NumModels: 0, | ||||
| NumWikiViews: repoGitStat.WikiPages, | |||||
| NumWikiViews: numWikiViews, | |||||
| NumCommits: repo.NumCommit, | NumCommits: repo.NumCommit, | ||||
| NumIssues: int64(repo.NumIssues), | NumIssues: int64(repo.NumIssues), | ||||
| NumPulls: int64(repo.NumPulls), | NumPulls: int64(repo.NumPulls), | ||||
| IssueFixedRate: issueFixedRate, | IssueFixedRate: issueFixedRate, | ||||
| NumContributor: repoGitStat.Contributors, | |||||
| NumKeyContributor: repoGitStat.KeyContributors, | |||||
| NumContributor: numContributor, | |||||
| NumKeyContributor: numKeyContributor, | |||||
| } | } | ||||
| if _, err = models.InsertRepoStat(&repoStat); err != nil { | 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) | log.Error("failed statistic: %s", repo.Name) | ||||
| continue | continue | ||||
| } | } | ||||
| @@ -114,14 +114,14 @@ func RouterHandler(level log.Level) func(ctx *macaron.Context) { | |||||
| } | } | ||||
| // SetLogMsgID set msgID in Context | // SetLogMsgID set msgID in Context | ||||
| func SetLogMsgID() func(ctx *macaron.Context) { | |||||
| func SetLogMsgID() macaron.Handler { | |||||
| return func(ctx *macaron.Context) { | return func(ctx *macaron.Context) { | ||||
| start := time.Now() | start := time.Now() | ||||
| uuid := gouuid.NewV4().String() | uuid := gouuid.NewV4().String() | ||||
| ctx.Data["MsgID"] = uuid | 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) | rw := ctx.Resp.(macaron.ResponseWriter) | ||||
| ctx.Next() | ctx.Next() | ||||
| @@ -149,7 +149,7 @@ func NewMacaron() *macaron.Macaron { | |||||
| m.Use(macaron.Logger()) | 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 | // Access Logger is similar to Router Log but more configurable and by default is more like the NCSA Common Log format | ||||
| if setting.EnableAccessLog { | if setting.EnableAccessLog { | ||||
| setupAccessLogger(m) | setupAccessLogger(m) | ||||
| @@ -257,6 +257,7 @@ func NewMacaron() *macaron.Macaron { | |||||
| DisableDebug: !setting.EnablePprof, | DisableDebug: !setting.EnablePprof, | ||||
| })) | })) | ||||
| m.Use(context.Contexter()) | m.Use(context.Contexter()) | ||||
| m.Use(SetLogMsgID()) | |||||
| // OK we are now set-up enough to allow us to create a nicer recovery than | // OK we are now set-up enough to allow us to create a nicer recovery than | ||||
| // the default macaron recovery | // the default macaron recovery | ||||
| m.Use(context.Recovery()) | m.Use(context.Recovery()) | ||||
| @@ -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="{{.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> | <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> | </div> | ||||
| {{if ne .DecompressState 0}} | |||||
| {{if eq .DecompressState 1}} | |||||
| <div class="ui left mini icon buttons"> | <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> | <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}} | {{if $.IsSigned}} | ||||