Skip to content

Commit 4d4eda4

Browse files
lunnysilverwind
authored andcommitted
Use prev/next pagination for user profile activities page to speed up (go-gitea#36642)
From my local test, it has 156,941 pages Before <img width="336" height="29" alt="image" src="https://github.com/user-attachments/assets/a02dee98-03b3-486e-9039-0743340f44df" /> After <img width="681" height="38" alt="image" src="https://github.com/user-attachments/assets/384ab534-e3a7-424e-9bdd-5e6fba02b621" />
1 parent f720110 commit 4d4eda4

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

routers/web/user/profile.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
103103
repos []*repo_model.Repository
104104
count int64
105105
total int
106+
curRows int
106107
orderBy db.SearchOrderBy
107108
)
108109

@@ -169,7 +170,7 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
169170
date := ctx.FormString("date")
170171
pagingNum = setting.UI.FeedPagingNum
171172
showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID)
172-
items, count, err := feed_service.GetFeeds(ctx, activities_model.GetFeedsOptions{
173+
items, feedCount, err := feed_service.GetFeedsForDashboard(ctx, activities_model.GetFeedsOptions{
173174
RequestedUser: ctx.ContextUser,
174175
Actor: ctx.Doer,
175176
IncludePrivate: showPrivate,
@@ -187,8 +188,8 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
187188
}
188189
ctx.Data["Feeds"] = items
189190
ctx.Data["Date"] = date
190-
191-
total = int(count)
191+
curRows = len(items)
192+
total = feedCount
192193
case "stars":
193194
ctx.Data["PageIsProfileStarList"] = true
194195
ctx.Data["ShowRepoOwnerOnList"] = true
@@ -310,6 +311,9 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
310311
}
311312

312313
pager := context.NewPagination(total, pagingNum, page, 5)
314+
if tab == "activity" {
315+
pager.WithCurRows(curRows)
316+
}
313317
pager.AddParamFromRequest(ctx.Req)
314318
ctx.Data["Page"] = pager
315319
}

0 commit comments

Comments
 (0)