summaryrefslogtreecommitdiff
path: root/internal/db/pg/pg.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-05-21 23:04:59 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-21 23:04:59 +0200
commit0df2e18cc0d5440deca32681f33c66d883913901 (patch)
treed52cb72f376695c70c37377fdb03ae47177e420e /internal/db/pg/pg.go
parentFollows and relationships (#27) (diff)
downloadgotosocial-0df2e18cc0d5440deca32681f33c66d883913901.tar.xz
Home timeline (#28)
* v. basic implementation of home timeline * Go fmt ./...
Diffstat (limited to 'internal/db/pg/pg.go')
-rw-r--r--internal/db/pg/pg.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/db/pg/pg.go b/internal/db/pg/pg.go
index 2a4b040d1..30b073bcc 100644
--- a/internal/db/pg/pg.go
+++ b/internal/db/pg/pg.go
@@ -1103,6 +1103,26 @@ func (ps *postgresService) WhoFavedStatus(status *gtsmodel.Status) ([]*gtsmodel.
return accounts, nil
}
+func (ps *postgresService) GetHomeTimelineForAccount(accountID string, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error) {
+ statuses := []*gtsmodel.Status{}
+
+ q := ps.conn.Model(&statuses).
+ ColumnExpr("status.*").
+ Join("JOIN follows AS f ON f.target_account_id = status.account_id").
+ Where("f.account_id = ?", accountID).
+ Limit(limit).
+ Order("status.created_at DESC")
+
+ err := q.Select()
+ if err != nil {
+ if err != pg.ErrNoRows {
+ return nil, err
+ }
+ }
+
+ return statuses, nil
+}
+
/*
CONVERSION FUNCTIONS
*/