From 8ed1b8142c93b4a0887ad4fde7eb7558f9ec7e08 Mon Sep 17 00:00:00 2001 From: Daenney Date: Wed, 3 Apr 2024 15:06:39 +0200 Subject: [bugfix] Sort follows chronologically (#2801) The id on the follows table is not a ULID, but a random ID. Sorting on them results in a completely random order. Instead, sort on created_at, which sould result in a stable and intended sort order. Fixes: #2769 Co-authored-by: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> --- internal/db/bundb/relationship.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'internal/db') diff --git a/internal/db/bundb/relationship.go b/internal/db/bundb/relationship.go index 30e3850d2..1c533af39 100644 --- a/internal/db/bundb/relationship.go +++ b/internal/db/bundb/relationship.go @@ -331,7 +331,7 @@ func newSelectFollows(db *bun.DB, accountID string) *bun.SelectQuery { Table("follows"). Column("id"). Where("? = ?", bun.Ident("account_id"), accountID). - OrderExpr("? DESC", bun.Ident("id")) + OrderExpr("? DESC", bun.Ident("created_at")) } // newSelectLocalFollows returns a new select query for all rows in the follows table with @@ -349,7 +349,7 @@ func newSelectLocalFollows(db *bun.DB, accountID string) *bun.SelectQuery { Column("id"). Where("? IS NULL", bun.Ident("domain")), ). - OrderExpr("? DESC", bun.Ident("id")) + OrderExpr("? DESC", bun.Ident("created_at")) } // newSelectFollowers returns a new select query for all rows in the follows table with target_account_id = accountID. @@ -358,7 +358,7 @@ func newSelectFollowers(db *bun.DB, accountID string) *bun.SelectQuery { Table("follows"). Column("id"). Where("? = ?", bun.Ident("target_account_id"), accountID). - OrderExpr("? DESC", bun.Ident("id")) + OrderExpr("? DESC", bun.Ident("created_at")) } // newSelectLocalFollowers returns a new select query for all rows in the follows table with @@ -376,7 +376,7 @@ func newSelectLocalFollowers(db *bun.DB, accountID string) *bun.SelectQuery { Column("id"). Where("? IS NULL", bun.Ident("domain")), ). - OrderExpr("? DESC", bun.Ident("id")) + OrderExpr("? DESC", bun.Ident("created_at")) } // newSelectBlocks returns a new select query for all rows in the blocks table with account_id = accountID. -- cgit v1.2.3