Skip to content

Commit

Permalink
Upstream data
Browse files Browse the repository at this point in the history
Signed-off-by: AbstractionFactory <[email protected]>
  • Loading branch information
abstractionfactory committed Sep 11, 2024
1 parent 37d49b9 commit 7e9ad36
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions backend/internal/providerindex/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ func (d *documentationGenerator) extractRepoInfo(ctx context.Context, addr provi
return
}
providerData.Description = repoInfo.Description
providerData.Popularity = repoInfo.Popularity
providerData.ForkCount = repoInfo.ForkCount

forkRepo := repoInfo.ForkOf
Expand All @@ -346,6 +347,14 @@ func (d *documentationGenerator) extractRepoInfo(ctx context.Context, addr provi
return
}
providerData.ForkOf = providertypes.Addr(forkedAddr)

upstreamRepoInfo, err := d.vcsClient.GetRepositoryInfo(ctx, *forkRepo)
if err != nil {
d.log.Warn(ctx, "Cannot fetch upstream repository info for %s (%v)", forkRepo.String(), err)
return
}
providerData.UpstreamPopularity = upstreamRepoInfo.Popularity
providerData.UpstreamForkCount = upstreamRepoInfo.ForkCount
}

func (d *documentationGenerator) scrapeVersion(ctx context.Context, addr providertypes.ProviderAddr, canonicalAddr provider.Addr, version provider.Version, blocked bool, blockedReason string) (providertypes.ProviderVersion, error) {
Expand Down
4 changes: 4 additions & 0 deletions backend/internal/providerindex/providertypes/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type Provider struct {
// ForkOf indicates which provider this repository is forked from. This field may be empty even if
// the ForkOfLink field is filled.
ForkOf ProviderAddr `json:"fork_of,omitempty"`
// UpstreamPopularity contains the popularity of the original repository this repository is forked of.
UpstreamPopularity int `json:"upstream_popularity"`
// UpstreamForkCount contains the number of forks of the upstream repository.
UpstreamForkCount int `json:"upstream_fork_count"`
// Versions holds the list of versions this provider supports.
//
// required: true
Expand Down
8 changes: 8 additions & 0 deletions backend/internal/server/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,14 @@ definitions:
items:
$ref: '#/definitions/ProviderAddr'
type: array
upstream_fork_count:
description: UpstreamForkCount contains the number of forks of the upstream repository.
format: int64
type: integer
upstream_popularity:
description: UpstreamPopularity contains the popularity of the original repository this repository is forked of.
format: int64
type: integer
versions:
description: Versions holds the list of versions this provider supports.
items:
Expand Down

0 comments on commit 7e9ad36

Please sign in to comment.