mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Remove redudant functions and code (#2652)
* Remove redudant functions and code
This commit is contained in:
		
				
					committed by
					
						 Kim "BKC" Carlbäcker
						Kim "BKC" Carlbäcker
					
				
			
			
				
	
			
			
			
						parent
						
							c2346e4469
						
					
				
				
					commit
					dff26e25ca
				
			| @@ -60,8 +60,7 @@ func Swagger(ctx *context.Context) { | ||||
|  | ||||
| // RepoSearchOptions when calling search repositories | ||||
| type RepoSearchOptions struct { | ||||
| 	Ranger   func(*models.SearchRepoOptions) (models.RepositoryList, int64, error) | ||||
| 	Searcher *models.User | ||||
| 	OwnerID  int64 | ||||
| 	Private  bool | ||||
| 	PageSize int | ||||
| 	TplName  base.TplName | ||||
| @@ -113,35 +112,21 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { | ||||
| 	} | ||||
|  | ||||
| 	keyword := strings.Trim(ctx.Query("q"), " ") | ||||
| 	if len(keyword) == 0 { | ||||
| 		repos, count, err = opts.Ranger(&models.SearchRepoOptions{ | ||||
| 			Page:        page, | ||||
| 			PageSize:    opts.PageSize, | ||||
| 			Searcher:    ctx.User, | ||||
| 			OrderBy:     orderBy, | ||||
| 			Private:     opts.Private, | ||||
| 			Collaborate: true, | ||||
| 		}) | ||||
| 		if err != nil { | ||||
| 			ctx.Handle(500, "opts.Ranger", err) | ||||
| 			return | ||||
| 		} | ||||
| 	} else { | ||||
| 		if isKeywordValid(keyword) { | ||||
| 			repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ | ||||
| 				Keyword:     keyword, | ||||
| 				OrderBy:     orderBy, | ||||
| 				Private:     opts.Private, | ||||
| 				Page:        page, | ||||
| 				PageSize:    opts.PageSize, | ||||
| 				Searcher:    ctx.User, | ||||
| 				Collaborate: true, | ||||
| 			}) | ||||
| 			if err != nil { | ||||
| 				ctx.Handle(500, "SearchRepositoryByName", err) | ||||
| 				return | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 	repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ | ||||
| 		Page:        page, | ||||
| 		PageSize:    opts.PageSize, | ||||
| 		OrderBy:     orderBy, | ||||
| 		Private:     opts.Private, | ||||
| 		Keyword:     keyword, | ||||
| 		OwnerID:     opts.OwnerID, | ||||
| 		Searcher:    ctx.User, | ||||
| 		Collaborate: true, | ||||
| 		AllPublic:   true, | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		ctx.Handle(500, "SearchRepositoryByName", err) | ||||
| 		return | ||||
| 	} | ||||
| 	ctx.Data["Keyword"] = keyword | ||||
| 	ctx.Data["Total"] = count | ||||
| @@ -157,11 +142,15 @@ func ExploreRepos(ctx *context.Context) { | ||||
| 	ctx.Data["PageIsExplore"] = true | ||||
| 	ctx.Data["PageIsExploreRepositories"] = true | ||||
|  | ||||
| 	var ownerID int64 | ||||
| 	if ctx.User != nil && !ctx.User.IsAdmin { | ||||
| 		ownerID = ctx.User.ID | ||||
| 	} | ||||
|  | ||||
| 	RenderRepoSearch(ctx, &RepoSearchOptions{ | ||||
| 		Ranger:   models.GetRecentUpdatedRepositories, | ||||
| 		PageSize: setting.UI.ExplorePagingNum, | ||||
| 		Searcher: ctx.User, | ||||
| 		Private:  ctx.User != nil && ctx.User.IsAdmin, | ||||
| 		OwnerID:  ownerID, | ||||
| 		Private:  ctx.User != nil, | ||||
| 		TplName:  tplExploreRepos, | ||||
| 	}) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user