From 9c0420161ec0954e35e761e65a5f44f3c8c2511d Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Tue, 24 Nov 2026 02:51:18 +0000 Subject: [PATCH] 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. --- pkg/metadata/file/dashboard.go | 2 +- pkg/metadata/gormstore/dashboard.go | 3 +-- pkg/metadata/gormstore/dashboard_test.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/metadata/file/dashboard.go b/pkg/metadata/file/dashboard.go index ded23b2..6a2d7c4 100644 --- a/pkg/metadata/file/dashboard.go +++ b/pkg/metadata/file/dashboard.go @@ -132,7 +132,7 @@ func (s *Store) GetRegistryStats(ctx context.Context) ([]metadata.RegistryStat, byRegistry := map[string]*metadata.RegistryStat{} var order []string for _, p := range all { - if metadata.IsMetadataVersion(p.Version) { + if metadata.IsMetadataEntry(p.Registry, p.Name, p.Version) { continue } st, ok := byRegistry[p.Registry] diff --git a/pkg/metadata/gormstore/dashboard.go b/pkg/metadata/gormstore/dashboard.go index d2d7649..ee88b99 100644 --- a/pkg/metadata/gormstore/dashboard.go +++ b/pkg/metadata/gormstore/dashboard.go @@ -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") diff --git a/pkg/metadata/gormstore/dashboard_test.go b/pkg/metadata/gormstore/dashboard_test.go index e7e8ded..cafca14 100644 --- a/pkg/metadata/gormstore/dashboard_test.go +++ b/pkg/metadata/gormstore/dashboard_test.go @@ -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"]) }