Use prev/next pagination for user profile activities page to speed up (#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" />
This commit is contained in:
@@ -103,6 +103,7 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
|
|||||||
repos []*repo_model.Repository
|
repos []*repo_model.Repository
|
||||||
count int64
|
count int64
|
||||||
total int
|
total int
|
||||||
|
curRows int
|
||||||
orderBy db.SearchOrderBy
|
orderBy db.SearchOrderBy
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -169,7 +170,7 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
|
|||||||
date := ctx.FormString("date")
|
date := ctx.FormString("date")
|
||||||
pagingNum = setting.UI.FeedPagingNum
|
pagingNum = setting.UI.FeedPagingNum
|
||||||
showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID)
|
showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID)
|
||||||
items, count, err := feed_service.GetFeeds(ctx, activities_model.GetFeedsOptions{
|
items, feedCount, err := feed_service.GetFeedsForDashboard(ctx, activities_model.GetFeedsOptions{
|
||||||
RequestedUser: ctx.ContextUser,
|
RequestedUser: ctx.ContextUser,
|
||||||
Actor: ctx.Doer,
|
Actor: ctx.Doer,
|
||||||
IncludePrivate: showPrivate,
|
IncludePrivate: showPrivate,
|
||||||
@@ -187,8 +188,8 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
|
|||||||
}
|
}
|
||||||
ctx.Data["Feeds"] = items
|
ctx.Data["Feeds"] = items
|
||||||
ctx.Data["Date"] = date
|
ctx.Data["Date"] = date
|
||||||
|
curRows = len(items)
|
||||||
total = int(count)
|
total = feedCount
|
||||||
case "stars":
|
case "stars":
|
||||||
ctx.Data["PageIsProfileStarList"] = true
|
ctx.Data["PageIsProfileStarList"] = true
|
||||||
ctx.Data["ShowRepoOwnerOnList"] = true
|
ctx.Data["ShowRepoOwnerOnList"] = true
|
||||||
@@ -310,6 +311,9 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
pager := context.NewPagination(total, pagingNum, page, 5)
|
pager := context.NewPagination(total, pagingNum, page, 5)
|
||||||
|
if tab == "activity" {
|
||||||
|
pager.WithCurRows(curRows)
|
||||||
|
}
|
||||||
pager.AddParamFromRequest(ctx.Req)
|
pager.AddParamFromRequest(ctx.Req)
|
||||||
ctx.Data["Page"] = pager
|
ctx.Data["Page"] = pager
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user