mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] move PopulateAccountStats() nil check often performed into function itself (#3158)
* move PopulateAccountStats() nil check often performed into function itself * fix test to take in mind we don't repopulate account stats if not-nil
This commit is contained in:
@@ -92,11 +92,9 @@ func (p *Processor) PinCreate(ctx context.Context, requestingAccount *gtsmodel.A
|
||||
}
|
||||
|
||||
// Ensure account stats populated.
|
||||
if requestingAccount.Stats == nil {
|
||||
if err := p.state.DB.PopulateAccountStats(ctx, requestingAccount); err != nil {
|
||||
err = gtserror.Newf("db error getting account stats: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
if err := p.state.DB.PopulateAccountStats(ctx, requestingAccount); err != nil {
|
||||
err = gtserror.Newf("db error getting account stats: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
pinnedCount := *requestingAccount.Stats.StatusesPinnedCount
|
||||
@@ -157,11 +155,9 @@ func (p *Processor) PinRemove(ctx context.Context, requestingAccount *gtsmodel.A
|
||||
}
|
||||
|
||||
// Ensure account stats populated.
|
||||
if requestingAccount.Stats == nil {
|
||||
if err := p.state.DB.PopulateAccountStats(ctx, requestingAccount); err != nil {
|
||||
err = gtserror.Newf("db error getting account stats: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
if err := p.state.DB.PopulateAccountStats(ctx, requestingAccount); err != nil {
|
||||
err = gtserror.Newf("db error getting account stats: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
targetStatus.PinnedAt = time.Time{}
|
||||
|
Reference in New Issue
Block a user