Browse Source

setting: able to config dashboard news feed paging number (#4247)

pull/4301/head
Unknwon 8 years ago
parent
commit
07a9cbe0a9
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      conf/app.ini
  2. 11
      models/action.go
  3. 4
      models/issue.go
  4. 48
      modules/bindata/bindata.go
  5. 1
      modules/setting/setting.go
  6. 6
      routers/user/home.go

2
conf/app.ini

@ -429,6 +429,8 @@ ORG_PAGING_NUM = 50
[ui.user]
; Number of repos that are showed in one page
REPO_PAGING_NUM = 15
; Number of news feeds that are showed in one page
NEWS_FEED_PAGING_NUM = 20
[i18n]
LANGS = en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR,gl-ES,uk-UA

11
models/action.go

@ -671,9 +671,14 @@ func MergePullRequestAction(actUser *User, repo *Repository, pull *Issue) error
// GetFeeds returns action list of given user in given context.
// actorID is the user who's requesting, ctxUserID is the user/org that is requested.
// actorID can be -1 when isProfile is true or to skip the permission check.
func GetFeeds(ctxUser *User, actorID, offset int64, isProfile bool) ([]*Action, error) {
actions := make([]*Action, 0, 20)
sess := x.Limit(20, int(offset)).Desc("id").Where("user_id = ?", ctxUser.ID)
func GetFeeds(ctxUser *User, actorID int64, page int, isProfile bool) ([]*Action, error) {
if page <= 0 {
page = 1
}
actions := make([]*Action, 0, setting.UI.User.NewsFeedPagingNum)
sess := x.Limit(setting.UI.User.NewsFeedPagingNum, (page-1)*setting.UI.User.NewsFeedPagingNum).
Desc("id").Where("user_id = ?", ctxUser.ID)
if isProfile {
sess.And("is_private = ?", false).And("act_user_id = ?", ctxUser.ID)
} else if actorID != -1 && ctxUser.IsOrganization() {

4
models/issue.go

@ -895,7 +895,7 @@ func buildIssuesQuery(opts *IssuesOptions) *xorm.Session {
if len(opts.RepoIDs) == 0 {
return nil
}
sess.In("issue.repo_id", base.Int64sToStrings(opts.RepoIDs)).And("issue.is_closed=?", opts.IsClosed)
sess.In("issue.repo_id", opts.RepoIDs).And("issue.is_closed=?", opts.IsClosed)
} else {
sess.Where("issue.is_closed=?", opts.IsClosed)
}
@ -930,7 +930,7 @@ func buildIssuesQuery(opts *IssuesOptions) *xorm.Session {
}
if len(opts.Labels) > 0 && opts.Labels != "0" {
labelIDs := base.StringsToInt64s(strings.Split(opts.Labels, ","))
labelIDs := strings.Split(opts.Labels, ",")
if len(labelIDs) > 0 {
sess.Join("INNER", "issue_label", "issue.id = issue_label.issue_id").In("issue_label.label_id", labelIDs)
}

48
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

1
modules/setting/setting.go

@ -279,6 +279,7 @@ var (
} `ini:"ui.admin"`
User struct {
RepoPagingNum int
NewsFeedPagingNum int
} `ini:"ui.user"`
}

6
routers/user/home.go

@ -52,8 +52,8 @@ func getDashboardContextUser(ctx *context.Context) *models.User {
// retrieveFeeds loads feeds from database by given context user.
// The user could be organization so it is not always the logged in user,
// which is why we have to explicitly pass the context user ID.
func retrieveFeeds(ctx *context.Context, ctxUser *models.User, userID, offset int64, isProfile bool) {
actions, err := models.GetFeeds(ctxUser, userID, offset, isProfile)
func retrieveFeeds(ctx *context.Context, ctxUser *models.User, userID int64, page int, isProfile bool) {
actions, err := models.GetFeeds(ctxUser, userID, page, isProfile)
if err != nil {
ctx.Handle(500, "GetFeeds", err)
return
@ -143,7 +143,7 @@ func Dashboard(ctx *context.Context) {
ctx.Data["MirrorCount"] = len(mirrors)
ctx.Data["Mirrors"] = mirrors
retrieveFeeds(ctx, ctxUser, ctx.User.ID, 0, false)
retrieveFeeds(ctx, ctxUser, ctx.User.ID, 1, false)
if ctx.Written() {
return
}

Loading…
Cancel
Save