mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-30 17:00:26 +08:00
优化IPBox访问日志查询
This commit is contained in:
@@ -20,8 +20,6 @@ func (this *IndexAction) Init() {
|
|||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
Ip string
|
Ip string
|
||||||
|
|
||||||
Partition int32 `default:"-1"`
|
|
||||||
}) {
|
}) {
|
||||||
this.Data["ip"] = params.Ip
|
this.Data["ip"] = params.Ip
|
||||||
|
|
||||||
@@ -104,9 +102,17 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["publicBlackIPLists"] = publicBlackIPListMaps
|
this.Data["publicBlackIPLists"] = publicBlackIPListMaps
|
||||||
|
|
||||||
// 访问日志
|
// 访问日志
|
||||||
|
var hasAccessLogs = false
|
||||||
|
for _, day := range []string{timeutil.Format("Ymd"), timeutil.Format("Ymd", time.Now().AddDate(0, 0, -1))} {
|
||||||
|
partitionsResp, err := this.RPC().HTTPAccessLogRPC().FindHTTPAccessLogPartitions(this.AdminContext(), &pb.FindHTTPAccessLogPartitionsRequest{Day: day})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, partition := range partitionsResp.ReversePartitions {
|
||||||
accessLogsResp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
accessLogsResp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
||||||
Partition: params.Partition,
|
Partition: partition,
|
||||||
Day: timeutil.Format("Ymd"),
|
Day: day,
|
||||||
Ip: params.Ip,
|
Ip: params.Ip,
|
||||||
Size: 20,
|
Size: 20,
|
||||||
})
|
})
|
||||||
@@ -114,26 +120,19 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var accessLogs = accessLogsResp.HttpAccessLogs
|
|
||||||
if len(accessLogs) == 0 {
|
|
||||||
// 查询昨天
|
|
||||||
accessLogsResp, err = this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
|
||||||
Partition: params.Partition,
|
|
||||||
Day: timeutil.Format("Ymd", time.Now().AddDate(0, 0, -1)),
|
|
||||||
Ip: params.Ip,
|
|
||||||
Size: 20,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
accessLogs = accessLogsResp.HttpAccessLogs
|
|
||||||
|
|
||||||
if len(accessLogs) == 0 {
|
var accessLogs = accessLogsResp.HttpAccessLogs
|
||||||
accessLogs = []*pb.HTTPAccessLog{}
|
if len(accessLogs) > 0 {
|
||||||
}
|
|
||||||
}
|
|
||||||
this.Data["accessLogs"] = accessLogs
|
this.Data["accessLogs"] = accessLogs
|
||||||
|
hasAccessLogs = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hasAccessLogs {
|
||||||
|
this.Data["accessLogs"] = []interface{}{}
|
||||||
|
}
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user