fix(metadata): leave Go metadata files out of the registry stats

GetRegistryStats counted Go .mod and .info rows while GetStats and the
package rows left them out. The overview registry table therefore
showed more Go packages than the totals. Both stores now use the
artifact filter.
This commit is contained in:
2026-11-24 02:51:18 +00:00
parent c685131865
commit 9c0420161e
3 changed files with 3 additions and 4 deletions
+1 -2
View File
@@ -353,9 +353,8 @@ func (s *GORMStoreV2) GetRegistryStats(ctx context.Context) ([]metadata.Registry
Size int64
Downloads int64
}
if err := s.db.WithContext(ctx).Model(&PackageModel{}).
if err := artifactPackages(s.db.WithContext(ctx).Model(&PackageModel{})).
Select("registry_id, COUNT(*) AS count, COALESCE(SUM(size), 0) AS size, COALESCE(SUM(access_count), 0) AS downloads").
Where("version NOT IN ?", metadata.MetadataVersions).
Group("registry_id").Order("registry_id").
Scan(&rows).Error; err != nil {
return nil, errors.Wrap(err, errors.ErrCodeStorageFailure, "failed to aggregate registry stats")
+1 -1
View File
@@ -296,7 +296,7 @@ func checkRegistryStats(t *testing.T, store *GORMStoreV2) {
got[s.Registry] = s
}
require.Equal(t, metadata.RegistryStat{Registry: "npm", Count: 6, Size: 100 + 110 + 300 + 900 + 10 + 20, Downloads: 3 + 1 + 7}, got["npm"], "the list page is excluded")
require.Equal(t, metadata.RegistryStat{Registry: "go", Count: 5, Size: 500 + 10 + 5 + 520 + 40, Downloads: 3}, got["go"])
require.Equal(t, metadata.RegistryStat{Registry: "go", Count: 3, Size: 500 + 520 + 40, Downloads: 3}, got["go"], "the .mod and .info files are excluded, as in GetStats")
require.Equal(t, metadata.RegistryStat{Registry: "pypi", Count: 2, Size: 80, Downloads: 4}, got["pypi"])
}