diff options
author | 2022-05-02 12:53:46 +0200 | |
---|---|---|
committer | 2022-05-02 11:53:46 +0100 | |
commit | a5852fd7e43bf97ea7def9de20cd6d02d954094d (patch) | |
tree | d72b7fe9bf603786a5533e6b566a8412b2b8f634 /internal/processing/admin/createdomainblock.go | |
parent | Add logging to the new generic worker package (#516) (diff) | |
download | gotosocial-a5852fd7e43bf97ea7def9de20cd6d02d954094d.tar.xz |
[performance] Speed up some of the slower db queries (#523)
* remove unnecessary LOWER() db calls
* warn during slow db queries
* use bundb built-in exists function
* add db block test
* update account block query
* add domain block db test
* optimize domain block query
* fix implementing wrong test
* exclude most columns when checking block
* go fmt
* remote more unnecessary use of LOWER()
Diffstat (limited to 'internal/processing/admin/createdomainblock.go')
-rw-r--r-- | internal/processing/admin/createdomainblock.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/processing/admin/createdomainblock.go b/internal/processing/admin/createdomainblock.go index 9bf7c2fd4..3cfaabce0 100644 --- a/internal/processing/admin/createdomainblock.go +++ b/internal/processing/admin/createdomainblock.go @@ -21,6 +21,7 @@ package admin import ( "context" "fmt" + "strings" "time" "github.com/sirupsen/logrus" @@ -35,9 +36,12 @@ import ( ) func (p *processor) DomainBlockCreate(ctx context.Context, account *gtsmodel.Account, domain string, obfuscate bool, publicComment string, privateComment string, subscriptionID string) (*apimodel.DomainBlock, gtserror.WithCode) { + // domain blocks will always be lowercase + domain = strings.ToLower(domain) + // first check if we already have a block -- if err == nil we already had a block so we can skip a whole lot of work domainBlock := >smodel.DomainBlock{} - err := p.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: domain, CaseInsensitive: true}}, domainBlock) + err := p.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: domain}}, domainBlock) if err != nil { if err != db.ErrNoEntries { // something went wrong in the DB @@ -95,7 +99,7 @@ func (p *processor) initiateDomainBlockSideEffects(ctx context.Context, account // if we have an instance entry for this domain, update it with the new block ID and clear all fields instance := >smodel.Instance{} - if err := p.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: block.Domain, CaseInsensitive: true}}, instance); err == nil { + if err := p.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: block.Domain}}, instance); err == nil { instance.Title = "" instance.UpdatedAt = time.Now() instance.SuspendedAt = time.Now() |