MCPcopy Create free account
hub / github.com/AndroidPoet/playconsole-cli / GetDownloadsByPlatform

Method GetDownloadsByPlatform

internal/api/github.go:121–152  ·  view source on GitHub ↗

GetDownloadsByPlatform returns download counts grouped by platform

()

Source from the content-addressed store, hash-verified

119
120// GetDownloadsByPlatform returns download counts grouped by platform
121func (c *GitHubClient) GetDownloadsByPlatform() ([]PlatformDownloads, int64, error) {
122 releases, err := c.GetReleases()
123 if err != nil {
124 return nil, 0, err
125 }
126
127 platformCounts := make(map[string]int64)
128 var total int64
129
130 for _, release := range releases {
131 for _, asset := range release.Assets {
132 platform := extractPlatform(asset.Name)
133 platformCounts[platform] += asset.DownloadCount
134 total += asset.DownloadCount
135 }
136 }
137
138 result := make([]PlatformDownloads, 0, len(platformCounts))
139 for platform, downloads := range platformCounts {
140 percent := float64(0)
141 if total > 0 {
142 percent = float64(downloads) / float64(total) * 100
143 }
144 result = append(result, PlatformDownloads{
145 Platform: platform,
146 Downloads: downloads,
147 Percent: fmt.Sprintf("%.1f%%", percent),
148 })
149 }
150
151 return result, total, nil
152}
153
154// ReleaseDownloads represents download stats for a release
155type ReleaseDownloads struct {

Callers 1

runDownloadsFunction · 0.95

Calls 2

GetReleasesMethod · 0.95
extractPlatformFunction · 0.85

Tested by

no test coverage detected