@@ -73,21 +73,26 @@ func Releases(ctx *context.Context) {
73
73
// Temproray cache commits count of used branches to speed up.
74
74
countCache := make (map [string ]int64 )
75
75
76
+ var cacheUsers = make (map [int64 ]* models.User )
77
+ var ok bool
76
78
tags := make ([]* models.Release , len (rawTags ))
77
79
for i , rawTag := range rawTags {
78
80
for j , r := range releases {
79
81
if r == nil || (r .IsDraft && ! ctx .Repo .IsOwner ()) {
80
82
continue
81
83
}
82
84
if r .TagName == rawTag {
83
- r .Publisher , err = models .GetUserByID (r .PublisherID )
84
- if err != nil {
85
- if models .IsErrUserNotExist (err ) {
86
- r .Publisher = models .NewGhostUser ()
87
- } else {
88
- ctx .Handle (500 , "GetUserByID" , err )
89
- return
85
+ if r .Publisher , ok = cacheUsers [r .PublisherID ]; ! ok {
86
+ r .Publisher , err = models .GetUserByID (r .PublisherID )
87
+ if err != nil {
88
+ if models .IsErrUserNotExist (err ) {
89
+ r .Publisher = models .NewGhostUser ()
90
+ } else {
91
+ ctx .Handle (500 , "GetUserByID" , err )
92
+ return
93
+ }
90
94
}
95
+ cacheUsers [r .PublisherID ] = r .Publisher
91
96
}
92
97
93
98
if err := calReleaseNumCommitsBehind (ctx .Repo , r , countCache ); err != nil {
@@ -129,14 +134,17 @@ func Releases(ctx *context.Context) {
129
134
continue
130
135
}
131
136
132
- r .Publisher , err = models .GetUserByID (r .PublisherID )
133
- if err != nil {
134
- if models .IsErrUserNotExist (err ) {
135
- r .Publisher = models .NewGhostUser ()
136
- } else {
137
- ctx .Handle (500 , "GetUserByID" , err )
138
- return
137
+ if r .Publisher , ok = cacheUsers [r .PublisherID ]; ! ok {
138
+ r .Publisher , err = models .GetUserByID (r .PublisherID )
139
+ if err != nil {
140
+ if models .IsErrUserNotExist (err ) {
141
+ r .Publisher = models .NewGhostUser ()
142
+ } else {
143
+ ctx .Handle (500 , "GetUserByID" , err )
144
+ return
145
+ }
139
146
}
147
+ cacheUsers [r .PublisherID ] = r .Publisher
140
148
}
141
149
142
150
if err := calReleaseNumCommitsBehind (ctx .Repo , r , countCache ); err != nil {
0 commit comments