mirror of https://github.com/gogs/gogs.git
setting: able to config dashboard news feed paging number (#4247)
parent
7c802f6d83
commit
07a9cbe0a9
|
@ -429,6 +429,8 @@ ORG_PAGING_NUM = 50
|
||||||
[ui.user]
|
[ui.user]
|
||||||
; Number of repos that are showed in one page
|
; Number of repos that are showed in one page
|
||||||
REPO_PAGING_NUM = 15
|
REPO_PAGING_NUM = 15
|
||||||
|
; Number of news feeds that are showed in one page
|
||||||
|
NEWS_FEED_PAGING_NUM = 20
|
||||||
|
|
||||||
[i18n]
|
[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
|
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
|
||||||
|
|
|
@ -671,9 +671,14 @@ func MergePullRequestAction(actUser *User, repo *Repository, pull *Issue) error
|
||||||
// GetFeeds returns action list of given user in given context.
|
// 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 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.
|
// 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) {
|
func GetFeeds(ctxUser *User, actorID int64, page int, isProfile bool) ([]*Action, error) {
|
||||||
actions := make([]*Action, 0, 20)
|
if page <= 0 {
|
||||||
sess := x.Limit(20, int(offset)).Desc("id").Where("user_id = ?", ctxUser.ID)
|
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 {
|
if isProfile {
|
||||||
sess.And("is_private = ?", false).And("act_user_id = ?", ctxUser.ID)
|
sess.And("is_private = ?", false).And("act_user_id = ?", ctxUser.ID)
|
||||||
} else if actorID != -1 && ctxUser.IsOrganization() {
|
} else if actorID != -1 && ctxUser.IsOrganization() {
|
||||||
|
|
|
@ -895,7 +895,7 @@ func buildIssuesQuery(opts *IssuesOptions) *xorm.Session {
|
||||||
if len(opts.RepoIDs) == 0 {
|
if len(opts.RepoIDs) == 0 {
|
||||||
return nil
|
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 {
|
} else {
|
||||||
sess.Where("issue.is_closed=?", opts.IsClosed)
|
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" {
|
if len(opts.Labels) > 0 && opts.Labels != "0" {
|
||||||
labelIDs := base.StringsToInt64s(strings.Split(opts.Labels, ","))
|
labelIDs := strings.Split(opts.Labels, ",")
|
||||||
if len(labelIDs) > 0 {
|
if len(labelIDs) > 0 {
|
||||||
sess.Join("INNER", "issue_label", "issue.id = issue_label.issue_id").In("issue_label.label_id", labelIDs)
|
sess.Join("INNER", "issue_label", "issue.id = issue_label.issue_id").In("issue_label.label_id", labelIDs)
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -278,7 +278,8 @@ var (
|
||||||
OrgPagingNum int
|
OrgPagingNum int
|
||||||
} `ini:"ui.admin"`
|
} `ini:"ui.admin"`
|
||||||
User struct {
|
User struct {
|
||||||
RepoPagingNum int
|
RepoPagingNum int
|
||||||
|
NewsFeedPagingNum int
|
||||||
} `ini:"ui.user"`
|
} `ini:"ui.user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ func getDashboardContextUser(ctx *context.Context) *models.User {
|
||||||
// retrieveFeeds loads feeds from database by given context user.
|
// retrieveFeeds loads feeds from database by given context user.
|
||||||
// The user could be organization so it is not always the logged in 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.
|
// 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) {
|
func retrieveFeeds(ctx *context.Context, ctxUser *models.User, userID int64, page int, isProfile bool) {
|
||||||
actions, err := models.GetFeeds(ctxUser, userID, offset, isProfile)
|
actions, err := models.GetFeeds(ctxUser, userID, page, isProfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "GetFeeds", err)
|
ctx.Handle(500, "GetFeeds", err)
|
||||||
return
|
return
|
||||||
|
@ -143,7 +143,7 @@ func Dashboard(ctx *context.Context) {
|
||||||
ctx.Data["MirrorCount"] = len(mirrors)
|
ctx.Data["MirrorCount"] = len(mirrors)
|
||||||
ctx.Data["Mirrors"] = mirrors
|
ctx.Data["Mirrors"] = mirrors
|
||||||
|
|
||||||
retrieveFeeds(ctx, ctxUser, ctx.User.ID, 0, false)
|
retrieveFeeds(ctx, ctxUser, ctx.User.ID, 1, false)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue