aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/user/profile.go
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2023-02-24 22:15:10 +0100
committerGitHub <noreply@github.com>2023-02-24 16:15:10 -0500
commitf4920c9c7f5947d3b6476610f39bc3492ab4ef3b (patch)
tree36a4063c1ec25766808a73a2190a50cf13a7b18d /routers/web/user/profile.go
parent740a5ecdd925aec8dcea3e73da07868f70cdacac (diff)
downloadgitea-f4920c9c7f5947d3b6476610f39bc3492ab4ef3b.tar.gz
gitea-f4920c9c7f5947d3b6476610f39bc3492ab4ef3b.zip
Add pagination for dashboard and user activity feeds (#22937)
Previously only the last few activities where available. This works for all activity and for activity on a date chosen on the heatmap.
Diffstat (limited to 'routers/web/user/profile.go')
-rw-r--r--routers/web/user/profile.go34
1 files changed, 25 insertions, 9 deletions
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index 4f0a816569..b445260459 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -119,6 +119,11 @@ func Profile(ctx *context.Context) {
page = 1
}
+ pagingNum := setting.UI.User.RepoPagingNum
+ if tab == "activity" {
+ pagingNum = setting.UI.FeedPagingNum
+ }
+
topicOnly := ctx.FormBool("topic")
var (
@@ -164,7 +169,7 @@ func Profile(ctx *context.Context) {
switch tab {
case "followers":
items, count, err := user_model.GetUserFollowers(ctx, ctx.ContextUser, ctx.Doer, db.ListOptions{
- PageSize: setting.UI.User.RepoPagingNum,
+ PageSize: pagingNum,
Page: page,
})
if err != nil {
@@ -176,7 +181,7 @@ func Profile(ctx *context.Context) {
total = int(count)
case "following":
items, count, err := user_model.GetUserFollowing(ctx, ctx.ContextUser, ctx.Doer, db.ListOptions{
- PageSize: setting.UI.User.RepoPagingNum,
+ PageSize: pagingNum,
Page: page,
})
if err != nil {
@@ -187,24 +192,32 @@ func Profile(ctx *context.Context) {
total = int(count)
case "activity":
- ctx.Data["Feeds"], err = activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{
+ date := ctx.FormString("date")
+ items, count, err := activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{
RequestedUser: ctx.ContextUser,
Actor: ctx.Doer,
IncludePrivate: showPrivate,
OnlyPerformedBy: true,
IncludeDeleted: false,
- Date: ctx.FormString("date"),
- ListOptions: db.ListOptions{PageSize: setting.UI.FeedPagingNum},
+ Date: date,
+ ListOptions: db.ListOptions{
+ PageSize: pagingNum,
+ Page: page,
+ },
})
if err != nil {
ctx.ServerError("GetFeeds", err)
return
}
+ ctx.Data["Feeds"] = items
+ ctx.Data["Date"] = date
+
+ total = int(count)
case "stars":
ctx.Data["PageIsProfileStarList"] = true
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
- PageSize: setting.UI.User.RepoPagingNum,
+ PageSize: pagingNum,
Page: page,
},
Actor: ctx.Doer,
@@ -236,7 +249,7 @@ func Profile(ctx *context.Context) {
case "watching":
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
- PageSize: setting.UI.User.RepoPagingNum,
+ PageSize: pagingNum,
Page: page,
},
Actor: ctx.Doer,
@@ -258,7 +271,7 @@ func Profile(ctx *context.Context) {
default:
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
- PageSize: setting.UI.User.RepoPagingNum,
+ PageSize: pagingNum,
Page: page,
},
Actor: ctx.Doer,
@@ -281,12 +294,15 @@ func Profile(ctx *context.Context) {
ctx.Data["Repos"] = repos
ctx.Data["Total"] = total
- pager := context.NewPagination(total, setting.UI.User.RepoPagingNum, page, 5)
+ pager := context.NewPagination(total, pagingNum, page, 5)
pager.SetDefaultParams(ctx)
pager.AddParam(ctx, "tab", "TabName")
if tab != "followers" && tab != "following" && tab != "activity" && tab != "projects" {
pager.AddParam(ctx, "language", "Language")
}
+ if tab == "activity" {
+ pager.AddParam(ctx, "date", "Date")
+ }
ctx.Data["Page"] = pager
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled