summaryrefslogtreecommitdiff
path: root/internal/db/bundb/instance.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-08-26 22:06:34 +0200
committerLibravatar GitHub <noreply@github.com>2021-08-26 22:06:34 +0200
commit30f688dbe283106162de80ad1759322794ecbf03 (patch)
treeb84634c3e896180ebd9fda3f3425e718e024f603 /internal/db/bundb/instance.go
parentfix broken db queries in auth (#160) (diff)
downloadgotosocial-30f688dbe283106162de80ad1759322794ecbf03.tar.xz
some more little fixes for all to enjoy (#161)
Diffstat (limited to 'internal/db/bundb/instance.go')
-rw-r--r--internal/db/bundb/instance.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/internal/db/bundb/instance.go b/internal/db/bundb/instance.go
index 141b255cf..ea7ae194b 100644
--- a/internal/db/bundb/instance.go
+++ b/internal/db/bundb/instance.go
@@ -37,20 +37,17 @@ type instanceDB struct {
func (i *instanceDB) CountInstanceUsers(ctx context.Context, domain string) (int, db.Error) {
q := i.conn.
NewSelect().
- Model(&[]*gtsmodel.Account{})
-
- if domain == i.config.Host {
- // if the domain is *this* domain, just count where the domain field is null
- q = q.WhereGroup(" AND ", whereEmptyOrNull("domain"))
- } else {
- q = q.Where("domain = ?", domain)
- }
-
- // don't count the instance account or suspended users
- q = q.
+ Model(&[]*gtsmodel.Account{}).
Where("username != ?", domain).
Where("? IS NULL", bun.Ident("suspended_at"))
+ if domain == i.config.Host {
+ // if the domain is *this* domain, just count where the domain field is null
+ q = q.WhereGroup(" AND ", whereEmptyOrNull("domain"))
+ } else {
+ q = q.Where("domain = ?", domain)
+ }
+
count, err := q.Count(ctx)
return count, processErrorResponse(err)