fix:analysis page bug

Closes #IATZDC
This commit is contained in:
samwaf
2024-10-11 09:01:45 +08:00
parent a590bdc363
commit d5667a6b1a
+8 -2
View File
@@ -120,9 +120,15 @@ func (receiver *WafStatService) StatHomeSumDayTopIPRangeApi(req request.WafStats
// 通过时间获取国家级别的 攻击数 访问数
func (receiver *WafStatService) StatAnalysisDayCountryRangeApi(req request.WafStatsAnalysisDayRangeCountryReq) []response2.WafAnalysisDayStats {
var CountOfRange []response2.WafAnalysisDayStats
if req.AttackType == "" {
global.GWAF_LOCAL_STATS_DB.Model(&model.StatsIPCityDay{}).Where("day between ? and ?",
req.StartDay, req.EndDay).Select(" country as Name ,sum(count) as Value").Group("country").Order("sum(count) desc").Scan(&CountOfRange)
global.GWAF_LOCAL_STATS_DB.Debug().Model(&model.StatsIPCityDay{}).Where("day between ? and ? and type = ? ",
req.StartDay, req.EndDay, req.AttackType).Select(" country as Name ,sum(count) as Value").Group("country").Order("sum(count) desc").Scan(&CountOfRange)
} else {
global.GWAF_LOCAL_STATS_DB.Model(&model.StatsIPCityDay{}).Where("day between ? and ? and type = ? ",
req.StartDay, req.EndDay, req.AttackType).Select(" country as Name ,sum(count) as Value").Group("country").Order("sum(count) desc").Scan(&CountOfRange)
}
return CountOfRange
}