Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/tangy/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ func (t *tangyImpl) MavenBuildList(ctx context.Context, repositoryHref, groupID,
}

// MavenRepositoryMetrics returns package and build counts for the latest version of a repository.
// Packages are distinct group_id/artifact_id pairs; builds are .pom artifacts.
// Packages are distinct group_id/artifact_id pairs. Builds are distinct package versions:
// group_id/artifact_id tuples paired with the base version after stripping Maven build suffixes such as .rhlw-00001.
func (t *tangyImpl) MavenRepositoryMetrics(ctx context.Context, repositoryHref string) (MavenRepositoryMetrics, error) {
if repositoryHref == "" {
return MavenRepositoryMetrics{}, nil
Expand Down Expand Up @@ -443,16 +444,19 @@ func (t *tangyImpl) MavenRepositoryMetrics(ctx context.Context, repositoryHref s
return MavenRepositoryMetrics{}, err
}

pomFilter := ` AND rp.filename LIKE '%.pom'`
artifactFrom := `
FROM maven_mavenartifact rp
` + innerUnion + pomFilter
` + innerUnion

metricsQuery := `
SELECT
(SELECT COUNT(DISTINCT (rp.group_id, rp.artifact_id))
` + artifactFrom + `) AS package_count,
(SELECT COUNT(*)
(SELECT COUNT(DISTINCT (
rp.group_id,
rp.artifact_id,
regexp_replace(rp.version, '\.[a-zA-Z]+-\d+$', '')
))
` + artifactFrom + `) AS build_count`

var metrics MavenRepositoryMetrics
Expand Down
Loading