From 6738fd5bb0193daf3e2b524105ff690e8bfc32f4 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:43:27 +0000 Subject: [feature/performance] sqlite pragma optimize on close (#2596) * wrap database drivers in order to handle error processing, hooks, etc * remove dead code * add code comment, remove unused blank imports --- internal/db/bundb/admin.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'internal/db/bundb/admin.go') diff --git a/internal/db/bundb/admin.go b/internal/db/bundb/admin.go index e189c508e..70ae68026 100644 --- a/internal/db/bundb/admin.go +++ b/internal/db/bundb/admin.go @@ -45,7 +45,7 @@ import ( const rsaKeyBits = 2048 type adminDB struct { - db *DB + db *bun.DB state *state.State } @@ -56,7 +56,7 @@ func (a *adminDB) IsUsernameAvailable(ctx context.Context, username string) (boo Column("account.id"). Where("? = ?", bun.Ident("account.username"), username). Where("? IS NULL", bun.Ident("account.domain")) - return a.db.NotExists(ctx, q) + return notExists(ctx, q) } func (a *adminDB) IsEmailAvailable(ctx context.Context, email string) (bool, error) { @@ -73,7 +73,7 @@ func (a *adminDB) IsEmailAvailable(ctx context.Context, email string) (bool, err TableExpr("? AS ?", bun.Ident("email_domain_blocks"), bun.Ident("email_domain_block")). Column("email_domain_block.id"). Where("? = ?", bun.Ident("email_domain_block.domain"), domain) - emailDomainBlocked, err := a.db.Exists(ctx, emailDomainBlockedQ) + emailDomainBlocked, err := exists(ctx, emailDomainBlockedQ) if err != nil { return false, err } @@ -88,7 +88,7 @@ func (a *adminDB) IsEmailAvailable(ctx context.Context, email string) (bool, err Column("user.id"). Where("? = ?", bun.Ident("user.email"), email). WhereOr("? = ?", bun.Ident("user.unconfirmed_email"), email) - return a.db.NotExists(ctx, q) + return notExists(ctx, q) } func (a *adminDB) NewSignup(ctx context.Context, newSignup gtsmodel.NewSignup) (*gtsmodel.User, error) { @@ -229,7 +229,7 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) error { Where("? = ?", bun.Ident("account.username"), username). Where("? IS NULL", bun.Ident("account.domain")) - exists, err := a.db.Exists(ctx, q) + exists, err := exists(ctx, q) if err != nil { return err } @@ -287,7 +287,7 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) error { TableExpr("? AS ?", bun.Ident("instances"), bun.Ident("instance")). Where("? = ?", bun.Ident("instance.domain"), host) - exists, err := a.db.Exists(ctx, q) + exists, err := exists(ctx, q) if err != nil { return err } -- cgit v1.2.3