mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Cache users on list releases (#527)
This commit is contained in:
		@@ -73,6 +73,8 @@ func Releases(ctx *context.Context) {
 | 
			
		||||
	// Temproray cache commits count of used branches to speed up.
 | 
			
		||||
	countCache := make(map[string]int64)
 | 
			
		||||
 | 
			
		||||
	var cacheUsers = make(map[int64]*models.User)
 | 
			
		||||
	var ok bool
 | 
			
		||||
	tags := make([]*models.Release, len(rawTags))
 | 
			
		||||
	for i, rawTag := range rawTags {
 | 
			
		||||
		for j, r := range releases {
 | 
			
		||||
@@ -80,6 +82,7 @@ func Releases(ctx *context.Context) {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			if r.TagName == rawTag {
 | 
			
		||||
				if r.Publisher, ok = cacheUsers[r.PublisherID]; !ok {
 | 
			
		||||
					r.Publisher, err = models.GetUserByID(r.PublisherID)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						if models.IsErrUserNotExist(err) {
 | 
			
		||||
@@ -89,6 +92,8 @@ func Releases(ctx *context.Context) {
 | 
			
		||||
							return
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					cacheUsers[r.PublisherID] = r.Publisher
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if err := calReleaseNumCommitsBehind(ctx.Repo, r, countCache); err != nil {
 | 
			
		||||
					ctx.Handle(500, "calReleaseNumCommitsBehind", err)
 | 
			
		||||
@@ -129,6 +134,7 @@ func Releases(ctx *context.Context) {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if r.Publisher, ok = cacheUsers[r.PublisherID]; !ok {
 | 
			
		||||
			r.Publisher, err = models.GetUserByID(r.PublisherID)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				if models.IsErrUserNotExist(err) {
 | 
			
		||||
@@ -138,6 +144,8 @@ func Releases(ctx *context.Context) {
 | 
			
		||||
					return
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			cacheUsers[r.PublisherID] = r.Publisher
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := calReleaseNumCommitsBehind(ctx.Repo, r, countCache); err != nil {
 | 
			
		||||
			ctx.Handle(500, "calReleaseNumCommitsBehind", err)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user