[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:
kim
2024-08-02 12:15:11 +00:00
committed by GitHub
parent 94e87610c4
commit 0f734a2410
8 changed files with 53 additions and 78 deletions

View File

@@ -113,13 +113,11 @@ func (c *Converter) AccountToAPIAccountSensitive(ctx context.Context, a *gtsmode
}
// Ensure account stats populated.
if a.Stats == nil {
if err := c.state.DB.PopulateAccountStats(ctx, a); err != nil {
return nil, gtserror.Newf(
"error getting stats for account %s: %w",
a.ID, err,
)
}
if err := c.state.DB.PopulateAccountStats(ctx, a); err != nil {
return nil, gtserror.Newf(
"error getting stats for account %s: %w",
a.ID, err,
)
}
// Populate the account's role permissions bitmap and highlightedness from its public role.