mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-27 06:46:01 +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:
@@ -113,9 +113,22 @@ func GetMigrations() []*gormigrate.Migration {
|
||||
return tx.Migrator().DropTable(&StatsSnapshotModel{})
|
||||
},
|
||||
},
|
||||
{
|
||||
// Serves the previous-week range read behind trending packages.
|
||||
ID: "202611250002",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return createIndexIfMissing(tx, &DownloadStatsDailyModel{}, dailyTimeIndex)
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error {
|
||||
return tx.Migrator().DropIndex(&DownloadStatsDailyModel{}, dailyTimeIndex)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// dailyTimeIndex is download_stats_daily (time_bucket).
|
||||
const dailyTimeIndex = "idx_stats_daily_time"
|
||||
|
||||
// scanPackageScannedAtIndex is scan_results (package_id, scanned_at).
|
||||
const scanPackageScannedAtIndex = "idx_scan_package_scanned_at"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user