mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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.
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							740a5ecdd9
						
					
				
				
					commit
					f4920c9c7f
				
			@@ -380,14 +380,14 @@ type GetFeedsOptions struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetFeeds returns actions according to the provided options
 | 
			
		||||
func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, error) {
 | 
			
		||||
func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, error) {
 | 
			
		||||
	if opts.RequestedUser == nil && opts.RequestedTeam == nil && opts.RequestedRepo == nil {
 | 
			
		||||
		return nil, fmt.Errorf("need at least one of these filters: RequestedUser, RequestedTeam, RequestedRepo")
 | 
			
		||||
		return nil, 0, fmt.Errorf("need at least one of these filters: RequestedUser, RequestedTeam, RequestedRepo")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cond, err := activityQueryCondition(opts)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
		return nil, 0, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	sess := db.GetEngine(ctx).Where(cond).
 | 
			
		||||
@@ -398,16 +398,16 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, error) {
 | 
			
		||||
	sess = db.SetSessionPagination(sess, &opts)
 | 
			
		||||
 | 
			
		||||
	actions := make([]*Action, 0, opts.PageSize)
 | 
			
		||||
 | 
			
		||||
	if err := sess.Desc("`action`.created_unix").Find(&actions); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("Find: %w", err)
 | 
			
		||||
	count, err := sess.Desc("`action`.created_unix").FindAndCount(&actions)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, 0, fmt.Errorf("FindAndCount: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := ActionList(actions).loadAttributes(ctx); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("LoadAttributes: %w", err)
 | 
			
		||||
		return nil, 0, fmt.Errorf("LoadAttributes: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return actions, nil
 | 
			
		||||
	return actions, count, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ActivityReadable return whether doer can read activities of user
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user