diff --git a/db/beatmap.go b/db/beatmap.go index 47b4c48..ba971a5 100644 --- a/db/beatmap.go +++ b/db/beatmap.go @@ -11,7 +11,7 @@ type Beatmapset struct { ID int `gorm:"primaryKey"` Artist string Title string - MapperID int + MapperID int `gorm:"mapper_id"` Mapper User `gorm:"foreignKey:MapperID"` LastUpdated time.Time `gorm:"last_updated"` } diff --git a/db/db.go b/db/db.go index 3026cfa..79f400d 100644 --- a/db/db.go +++ b/db/db.go @@ -162,3 +162,14 @@ func (db *Db) GetUser(userId int) (user *User, err error) { return } + +type Stats struct { + TotalMaps int64 + TotalUsers int64 +} + +func (db *Db) GetStats() (stats Stats) { + db.gorm.Model(&Beatmapset{}).Count(&stats.TotalMaps) + db.gorm.Model(&Beatmapset{}).Group("mapper_id").Count(&stats.TotalUsers) + return +} diff --git a/web/templates/index.html b/web/templates/index.html index 94c8a38..b6d74ea 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -1,6 +1,10 @@ {{ define "content" }} -
Last 10 Updated Beatmaps:
+