Browse Source

add hot,active

tags/v1.21.12.1
lewis 4 years ago
parent
commit
8c4b79bdd4
2 changed files with 8 additions and 0 deletions
  1. +3
    -0
      models/repo.go
  2. +5
    -0
      routers/home.go

+ 3
- 0
models/repo.go View File

@@ -214,6 +214,9 @@ type Repository struct {

CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`

Hot int64 `xorm:"-"`
Active int64 `xorm:"-"`
}

// SanitizedOriginalURL returns a sanitized OriginalURL


+ 5
- 0
routers/home.go View File

@@ -171,6 +171,11 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
ctx.ServerError("SearchRepository", err)
return
}

for _, repo := range repos {
repo.Hot = int64(repo.NumWatches) + int64(repo.NumStars) + int64(repo.NumForks) + int64(repo.CloneCnt)
repo.Active = int64(repo.NumIssues) + int64(repo.NumPulls) + int64(repo.NumCommit)
}
ctx.Data["Keyword"] = keyword
ctx.Data["Total"] = count
ctx.Data["Repos"] = repos


Loading…
Cancel
Save