Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some more little fixes for all to enjoy #161

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/db/bundb/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ func (a *accountDB) GetAccountStatuses(ctx context.Context, accountID string, li
q = q.Limit(limit)
}

if excludeReplies {
q = q.WhereGroup(" AND ", whereEmptyOrNull("in_reply_to_id"))
}

if pinnedOnly {
q = q.Where("pinned = ?", true)
}
Expand All @@ -237,6 +233,10 @@ func (a *accountDB) GetAccountStatuses(ctx context.Context, accountID string, li
})
}

if excludeReplies {
q = q.WhereGroup(" AND ", whereEmptyOrNull("in_reply_to_id"))
}

if err := q.Scan(ctx); err != nil {
return nil, err
}
Expand Down
19 changes: 8 additions & 11 deletions internal/db/bundb/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/db/bundb/relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (r *relationshipDB) AcceptFollowRequest(ctx context.Context, originAccountI
if _, err := r.conn.
NewInsert().
Model(follow).
On("CONFLICT CONSTRAINT follows_account_id_target_account_id_key DO UPDATE set uri = ?", follow.URI).
On("CONFLICT ON CONSTRAINT follows_account_id_target_account_id_key DO UPDATE set uri = ?", follow.URI).
Exec(ctx); err != nil {
return nil, processErrorResponse(err)
}
Expand Down