[bugfix] Use ptr for instance stats entries to avoid skipping 0 values (#2666)

* [bugfix] Use ptr for instance stats entries to avoid skipping 0 values

* comment explaining why stats values are pointers
This commit is contained in:
tobi
2024-02-19 13:17:14 +01:00
committed by GitHub
parent 0554550acb
commit d10226e912
3 changed files with 10 additions and 8 deletions

View File

@@ -1024,24 +1024,24 @@ func (c *Converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins
instance.URLs.StreamingAPI = "wss://" + i.Domain
// statistics
stats := make(map[string]int, 3)
stats := make(map[string]*int, 3)
userCount, err := c.state.DB.CountInstanceUsers(ctx, i.Domain)
if err != nil {
return nil, fmt.Errorf("InstanceToAPIV1Instance: db error getting counting instance users: %w", err)
}
stats["user_count"] = userCount
stats["user_count"] = util.Ptr(userCount)
statusCount, err := c.state.DB.CountInstanceStatuses(ctx, i.Domain)
if err != nil {
return nil, fmt.Errorf("InstanceToAPIV1Instance: db error getting counting instance statuses: %w", err)
}
stats["status_count"] = statusCount
stats["status_count"] = util.Ptr(statusCount)
domainCount, err := c.state.DB.CountInstanceDomains(ctx, i.Domain)
if err != nil {
return nil, fmt.Errorf("InstanceToAPIV1Instance: db error getting counting instance domains: %w", err)
}
stats["domain_count"] = domainCount
stats["domain_count"] = util.Ptr(domainCount)
instance.Stats = stats
// thumbnail