@@ -98,19 +98,14 @@ func (repos RepositoryList) IDs() []int64 {
9898	return  repoIDs 
9999}
100100
101- // LoadAttributes loads the attributes for the given RepositoryList 
102- func  (repos  RepositoryList ) LoadAttributes (ctx  context.Context ) error  {
101+ func  (repos  RepositoryList ) LoadOwners (ctx  context.Context ) error  {
103102	if  len (repos ) ==  0  {
104103		return  nil 
105104	}
106105
107106	userIDs  :=  container .FilterSlice (repos , func (repo  * Repository ) (int64 , bool ) {
108107		return  repo .OwnerID , true 
109108	})
110- 	repoIDs  :=  make ([]int64 , len (repos ))
111- 	for  i  :=  range  repos  {
112- 		repoIDs [i ] =  repos [i ].ID 
113- 	}
114109
115110	// Load owners. 
116111	users  :=  make (map [int64 ]* user_model.User , len (userIDs ))
@@ -123,12 +118,19 @@ func (repos RepositoryList) LoadAttributes(ctx context.Context) error {
123118	for  i  :=  range  repos  {
124119		repos [i ].Owner  =  users [repos [i ].OwnerID ]
125120	}
121+ 	return  nil 
122+ }
123+ 
124+ func  (repos  RepositoryList ) LoadLanguageStats (ctx  context.Context ) error  {
125+ 	if  len (repos ) ==  0  {
126+ 		return  nil 
127+ 	}
126128
127129	// Load primary language. 
128130	stats  :=  make (LanguageStatList , 0 , len (repos ))
129131	if  err  :=  db .GetEngine (ctx ).
130132		Where ("`is_primary` = ? AND `language` != ?" , true , "other" ).
131- 		In ("`repo_id`" , repoIDs ).
133+ 		In ("`repo_id`" , repos . IDs () ).
132134		Find (& stats ); err  !=  nil  {
133135		return  fmt .Errorf ("find primary languages: %w" , err )
134136	}
@@ -141,10 +143,18 @@ func (repos RepositoryList) LoadAttributes(ctx context.Context) error {
141143			}
142144		}
143145	}
144- 
145146	return  nil 
146147}
147148
149+ // LoadAttributes loads the attributes for the given RepositoryList 
150+ func  (repos  RepositoryList ) LoadAttributes (ctx  context.Context ) error  {
151+ 	if  err  :=  repos .LoadOwners (ctx ); err  !=  nil  {
152+ 		return  err 
153+ 	}
154+ 
155+ 	return  repos .LoadLanguageStats (ctx )
156+ }
157+ 
148158// SearchRepoOptions holds the search options 
149159type  SearchRepoOptions  struct  {
150160	db.ListOptions 
0 commit comments