mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 10:12:26 -05:00
[performance] use GetAccountByUsernameDomain() for local account lookups to rely on cache (#793)
Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
1e1cdee06a
commit
614ab12733
19 changed files with 29 additions and 42 deletions
|
|
@ -91,11 +91,13 @@ func (a *accountDB) GetAccountByUsernameDomain(ctx context.Context, username str
|
|||
return a.cache.GetByUsernameDomain(username, domain)
|
||||
},
|
||||
func(account *gtsmodel.Account) error {
|
||||
q := a.newAccountQ(account).Where("account.username = ?", username)
|
||||
q := a.newAccountQ(account)
|
||||
|
||||
if domain != "" {
|
||||
q = q.Where("account.username = ?", username)
|
||||
q = q.Where("account.domain = ?", domain)
|
||||
} else {
|
||||
q = q.Where("account.username = ?", strings.ToLower(username))
|
||||
q = q.Where("account.domain IS NULL")
|
||||
}
|
||||
|
||||
|
|
@ -217,19 +219,6 @@ func (a *accountDB) SetAccountHeaderOrAvatar(ctx context.Context, mediaAttachmen
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *accountDB) GetLocalAccountByUsername(ctx context.Context, username string) (*gtsmodel.Account, db.Error) {
|
||||
account := new(gtsmodel.Account)
|
||||
|
||||
q := a.newAccountQ(account).
|
||||
Where("username = ?", strings.ToLower(username)). // usernames on our instance will always be lowercase
|
||||
WhereGroup(" AND ", whereEmptyOrNull("domain"))
|
||||
|
||||
if err := q.Scan(ctx); err != nil {
|
||||
return nil, a.conn.ProcessError(err)
|
||||
}
|
||||
return account, nil
|
||||
}
|
||||
|
||||
func (a *accountDB) GetAccountFaves(ctx context.Context, accountID string) ([]*gtsmodel.StatusFave, db.Error) {
|
||||
faves := new([]*gtsmodel.StatusFave)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue