mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 06:21:11 +00:00 
			
		
		
		
	Use db.Find instead of writing methods for every object (#28084)
For those simple objects, it's unnecessary to write the find and count methods again and again.
This commit is contained in:
		
					parent
					
						
							
								d24a8223ce
							
						
					
				
			
			
				commit
				
					
						df1e7d0067
					
				
			
		
					 88 changed files with 611 additions and 685 deletions
				
			
		|  | @ -9,6 +9,7 @@ import ( | |||
| 	"sort" | ||||
| 
 | ||||
| 	auth_model "code.gitea.io/gitea/models/auth" | ||||
| 	"code.gitea.io/gitea/models/db" | ||||
| 	user_model "code.gitea.io/gitea/models/user" | ||||
| 	"code.gitea.io/gitea/modules/base" | ||||
| 	"code.gitea.io/gitea/modules/context" | ||||
|  | @ -68,14 +69,17 @@ func loadSecurityData(ctx *context.Context) { | |||
| 	} | ||||
| 	ctx.Data["WebAuthnCredentials"] = credentials | ||||
| 
 | ||||
| 	tokens, err := auth_model.ListAccessTokens(ctx, auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID}) | ||||
| 	tokens, err := db.Find[auth_model.AccessToken](ctx, auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID}) | ||||
| 	if err != nil { | ||||
| 		ctx.ServerError("ListAccessTokens", err) | ||||
| 		return | ||||
| 	} | ||||
| 	ctx.Data["Tokens"] = tokens | ||||
| 
 | ||||
| 	accountLinks, err := user_model.ListAccountLinks(ctx, ctx.Doer) | ||||
| 	accountLinks, err := db.Find[user_model.ExternalLoginUser](ctx, user_model.FindExternalUserOptions{ | ||||
| 		UserID:  ctx.Doer.ID, | ||||
| 		OrderBy: "login_source_id DESC", | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		ctx.ServerError("ListAccountLinks", err) | ||||
| 		return | ||||
|  | @ -107,7 +111,7 @@ func loadSecurityData(ctx *context.Context) { | |||
| 	} | ||||
| 	ctx.Data["AccountLinks"] = sources | ||||
| 
 | ||||
| 	authSources, err := auth_model.FindSources(ctx, auth_model.FindSourcesOptions{ | ||||
| 	authSources, err := db.Find[auth_model.Source](ctx, auth_model.FindSourcesOptions{ | ||||
| 		IsActive:  util.OptionalBoolNone, | ||||
| 		LoginType: auth_model.OAuth2, | ||||
| 	}) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue