diff options
author | 2024-04-16 13:10:13 +0200 | |
---|---|---|
committer | 2024-04-16 13:10:13 +0200 | |
commit | 3cceed11b28b5f42a653d85ed779d652fd8c26ad (patch) | |
tree | 0a7f0994e477609ca705a45f382dfb62056b196e /internal/processing/account/rss.go | |
parent | [performance] cached oauth database types (#2838) (diff) | |
download | gotosocial-3cceed11b28b5f42a653d85ed779d652fd8c26ad.tar.xz |
[feature/performance] Store account stats in separate table (#2831)
* [feature/performance] Store account stats in separate table, get stats from remote
* test account stats
* add some missing increment / decrement calls
* change stats function signatures
* rejig logging a bit
* use lock when updating stats
Diffstat (limited to 'internal/processing/account/rss.go')
-rw-r--r-- | internal/processing/account/rss.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/processing/account/rss.go b/internal/processing/account/rss.go index f2c6cba5e..cbbb4875b 100644 --- a/internal/processing/account/rss.go +++ b/internal/processing/account/rss.go @@ -69,14 +69,18 @@ func (p *Processor) GetRSSFeedForUsername(ctx context.Context, username string) return nil, never, gtserror.NewErrorNotFound(err) } + // Ensure account stats populated. + if account.Stats == nil { + if err := p.state.DB.PopulateAccountStats(ctx, account); err != nil { + err = gtserror.Newf("db error getting account stats %s: %w", username, err) + return nil, never, gtserror.NewErrorInternalError(err) + } + } + // LastModified time is needed by callers to check freshness for cacheing. // This might be a zero time.Time if account has never posted a status that's // eligible to appear in the RSS feed; that's fine. - lastPostAt, err := p.state.DB.GetAccountLastPosted(ctx, account.ID, true) - if err != nil && !errors.Is(err, db.ErrNoEntries) { - err = gtserror.Newf("db error getting account %s last posted: %w", username, err) - return nil, never, gtserror.NewErrorInternalError(err) - } + lastPostAt := account.Stats.LastStatusAt return func() (string, gtserror.WithCode) { // Assemble author namestring once only. |