mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-15 23:26:35 +08:00
查询5分钟流量接口增加timeFrom和timeTo参数
This commit is contained in:
@@ -439,15 +439,24 @@ func (this *ServerDailyStatDAO) FindDailyStats(tx *dbs.Tx, serverId int64, dayFr
|
||||
|
||||
// FindStatsWithDay 按天查找5分钟级统计
|
||||
// day YYYYMMDD
|
||||
func (this *ServerDailyStatDAO) FindStatsWithDay(tx *dbs.Tx, serverId int64, day string) (result []*ServerDailyStat, err error) {
|
||||
func (this *ServerDailyStatDAO) FindStatsWithDay(tx *dbs.Tx, serverId int64, day string, timeFrom string, timeTo string) (result []*ServerDailyStat, err error) {
|
||||
if !regexp.MustCompile(`^\d{8}$`).MatchString(day) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.Query(tx).
|
||||
var query = this.Query(tx).
|
||||
Attr("serverId", serverId).
|
||||
Attr("day", day).
|
||||
AscPk().
|
||||
DescPk()
|
||||
|
||||
if len(timeFrom) > 0 {
|
||||
query.Gte("timeFrom", timeFrom)
|
||||
}
|
||||
if len(timeTo) > 0 {
|
||||
query.Lte("timeTo", timeTo)
|
||||
}
|
||||
|
||||
_, err = query.
|
||||
Slice(&result).
|
||||
FindAll()
|
||||
return
|
||||
|
||||
@@ -204,7 +204,7 @@ func (this *ServerDailyStatService) FindServer5MinutelyStatsWithDay(ctx context.
|
||||
req.Day = timeutil.Format("Ymd")
|
||||
}
|
||||
|
||||
dailyStats, err := models.SharedServerDailyStatDAO.FindStatsWithDay(tx, req.ServerId, req.Day)
|
||||
dailyStats, err := models.SharedServerDailyStatDAO.FindStatsWithDay(tx, req.ServerId, req.Day, req.TimeFrom, req.TimeTo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user