mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
feat(analytics): serve trending packages from persisted downloads
Trending read the in-memory analytics engine, which restarts empty. The endpoint now ranks packages by the last 7 days of stored downloads and reports the previous 7 days for the change. It counts a Go module once and skips metadata entries. A daily time_bucket index serves the range read. The Overview panel shows the change and no longer says the data resets on restart.
This commit is contained in:
@@ -443,3 +443,17 @@ func DedupeVersions(rows []*Package) []*Package {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// TrendingPackage is a package's download count over the last 7 days and the 7 days before.
|
||||
type TrendingPackage struct {
|
||||
Registry string `json:"registry"`
|
||||
Name string `json:"name"`
|
||||
Recent int64 `json:"recent"`
|
||||
Previous int64 `json:"previous"`
|
||||
}
|
||||
|
||||
// TrendingSource ranks packages from persisted download history. Backends without
|
||||
// persisted downloads do not implement it.
|
||||
type TrendingSource interface {
|
||||
GetTrendingPackages(ctx context.Context, limit int) ([]*TrendingPackage, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user