feat: add admin statistics (#59)

This commit is contained in:
Buer
2024-02-01 18:45:53 +08:00
committed by GitHub
parent f2aafab0d9
commit 332b6fd397
20 changed files with 1225 additions and 65 deletions

View File

@@ -182,3 +182,13 @@ func DeleteDisabledChannel() (int64, error) {
result := DB.Where("status = ? or status = ?", common.ChannelStatusAutoDisabled, common.ChannelStatusManuallyDisabled).Delete(&Channel{})
return result.RowsAffected, result.Error
}
type ChannelStatistics struct {
TotalChannels int `json:"total_channels"`
Status int `json:"status"`
}
func GetStatisticsChannel() (statistics []*ChannelStatistics, err error) {
err = DB.Table("channels").Select("count(*) as total_channels, status").Group("status").Scan(&statistics).Error
return statistics, err
}