summaryrefslogtreecommitdiff
path: root/internal/db/bundb/relationship.go
diff options
context:
space:
mode:
authorLibravatar Blackle Morisanchetto <isabelle@blackle-mori.com>2022-08-31 05:27:39 -0400
committerLibravatar GitHub <noreply@github.com>2022-08-31 11:27:39 +0200
commitdaec9ab10e192f82155ecf46d4ab257ca6655c24 (patch)
tree190723311fcf6ee25e55f2c1a7555ca289ccd1c5 /internal/db/bundb/relationship.go
parent[bugfix] Fix tusky search issue by returning empty if offset is greater than ... (diff)
downloadgotosocial-daec9ab10e192f82155ecf46d4ab257ca6655c24.tar.xz
[feature] Sort follow requests, followers, and following by updated_at (#774)
* Sort follow requests, followers, and following by updated_at * Add migration to regenerate indexes for follows and follow requests
Diffstat (limited to 'internal/db/bundb/relationship.go')
-rw-r--r--internal/db/bundb/relationship.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/internal/db/bundb/relationship.go b/internal/db/bundb/relationship.go
index 60dd72663..ba72a053a 100644
--- a/internal/db/bundb/relationship.go
+++ b/internal/db/bundb/relationship.go
@@ -292,7 +292,8 @@ func (r *relationshipDB) GetAccountFollowRequests(ctx context.Context, accountID
followRequests := []*gtsmodel.FollowRequest{}
q := r.newFollowQ(&followRequests).
- Where("target_account_id = ?", accountID)
+ Where("target_account_id = ?", accountID).
+ Order("follow_request.updated_at DESC")
if err := q.Scan(ctx); err != nil {
return nil, r.conn.ProcessError(err)
@@ -304,7 +305,8 @@ func (r *relationshipDB) GetAccountFollows(ctx context.Context, accountID string
follows := []*gtsmodel.Follow{}
q := r.newFollowQ(&follows).
- Where("account_id = ?", accountID)
+ Where("account_id = ?", accountID).
+ Order("follow.updated_at DESC")
if err := q.Scan(ctx); err != nil {
return nil, r.conn.ProcessError(err)
@@ -325,7 +327,8 @@ func (r *relationshipDB) GetAccountFollowedBy(ctx context.Context, accountID str
q := r.conn.
NewSelect().
- Model(&follows)
+ Model(&follows).
+ Order("follow.updated_at DESC")
if localOnly {
q = q.ColumnExpr("follow.*").