misc changes
This commit is contained in:
parent
8512402488
commit
8cb9c51bde
@ -24,7 +24,7 @@ func GetIPs(ctx *context.Context, config *config.Config, limit int) (apimailboxe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIPs ...
|
// GetIPsLast ...
|
||||||
func GetIPsLast(ctx *context.Context, config *config.Config, interval string) (apimailboxes []*api.IP, err error) {
|
func GetIPsLast(ctx *context.Context, config *config.Config, interval string) (apimailboxes []*api.IP, err error) {
|
||||||
var ips []IP
|
var ips []IP
|
||||||
err = config.Db.Where(fmt.Sprintf("updated >= (now()-'%s'::interval)", interval)).GroupBy("ip").Find(&ips)
|
err = config.Db.Where(fmt.Sprintf("updated >= (now()-'%s'::interval)", interval)).GroupBy("ip").Find(&ips)
|
||||||
|
@ -52,14 +52,8 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) {
|
|||||||
ret, err := models.GetIPs(ctx, cfg, limit)
|
ret, err := models.GetIPs(ctx, cfg, limit)
|
||||||
return Result(c, err, ret)
|
return Result(c, err, ret)
|
||||||
})
|
})
|
||||||
// retro-compat
|
|
||||||
e.GET("/ips/lastday", func(c echo.Context) (err error) {
|
|
||||||
interval := "1 day"
|
|
||||||
ret, err := models.GetIPsLast(ctx, cfg, interval)
|
|
||||||
return Result(c, err, ret)
|
|
||||||
})
|
|
||||||
e.GET("/ips/last", func(c echo.Context) (err error) {
|
e.GET("/ips/last", func(c echo.Context) (err error) {
|
||||||
interval := "10 minutes"
|
interval := "30 minutes"
|
||||||
ret, err := models.GetIPsLast(ctx, cfg, interval)
|
ret, err := models.GetIPsLast(ctx, cfg, interval)
|
||||||
return Result(c, err, ret)
|
return Result(c, err, ret)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user