fix(log): update sorting logic for server and user subscribe traffic logs
This commit is contained in:
parent
fe629e59dd
commit
3e5284c4ec
@ -43,7 +43,7 @@ func (l *FilterServerTrafficLogLogic) FilterServerTrafficLog(req *types.FilterSe
|
||||
Select("server_id, SUM(download + upload) AS total, SUM(download) AS download, SUM(upload) AS upload").
|
||||
Where("timestamp BETWEEN ? AND ?", start, end).
|
||||
Group("server_id").
|
||||
Order("id DESC").
|
||||
Order("SUM(download + upload) DESC").
|
||||
Scan(&serverTraffic).Error
|
||||
if err != nil {
|
||||
l.Errorw("[FilterServerTrafficLog] Query Database Error", logger.Field("error", err.Error()))
|
||||
|
||||
@ -29,6 +29,13 @@ func NewFilterUserSubscribeTrafficLogLogic(ctx context.Context, svcCtx *svc.Serv
|
||||
}
|
||||
|
||||
func (l *FilterUserSubscribeTrafficLogLogic) FilterUserSubscribeTrafficLog(req *types.FilterSubscribeTrafficRequest) (resp *types.FilterSubscribeTrafficResponse, err error) {
|
||||
if req.Size <= 0 {
|
||||
req.Size = 10
|
||||
}
|
||||
if req.Page <= 0 {
|
||||
req.Page = 1
|
||||
}
|
||||
|
||||
today := time.Now().Format("2006-01-02")
|
||||
var list []types.UserSubscribeTrafficLog
|
||||
var total int64
|
||||
@ -44,7 +51,7 @@ func (l *FilterUserSubscribeTrafficLogLogic) FilterUserSubscribeTrafficLog(req *
|
||||
Select("user_id, subscribe_id, SUM(download + upload) AS total, SUM(download) AS download, SUM(upload) AS upload").
|
||||
Where("timestamp BETWEEN ? AND ?", start, end).
|
||||
Group("user_id, subscribe_id").
|
||||
Order("id DESC").
|
||||
Order("SUM(download + upload) DESC").
|
||||
Scan(&userTraffic).Error
|
||||
if err != nil {
|
||||
l.Errorw("[FilterUserSubscribeTrafficLog] Query Database Error", logger.Field("error", err.Error()))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user