updated "last" endpoint
This commit is contained in:
parent
4f66f6fddd
commit
7d36b8e6fe
@ -25,7 +25,7 @@ func GetIPs(ctx *context.Context, config *config.Config, limit int) (apimailboxe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetIPs ...
|
// GetIPs ...
|
||||||
func GetIPsLastDay(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)).Asc("id").Find(&ips)
|
err = config.Db.Where(fmt.Sprintf("updated >= (now()-'%s'::interval)", interval)).Asc("id").Find(&ips)
|
||||||
for _, ml := range ips {
|
for _, ml := range ips {
|
||||||
|
@ -52,9 +52,15 @@ 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 JSONResult(c, err, ret)
|
return JSONResult(c, err, ret)
|
||||||
})
|
})
|
||||||
|
// retro-compat
|
||||||
e.GET("/ips/lastday", func(c echo.Context) (err error) {
|
e.GET("/ips/lastday", func(c echo.Context) (err error) {
|
||||||
interval := "1 day"
|
interval := "1 day"
|
||||||
ret, err := models.GetIPsLastDay(ctx, cfg, interval)
|
ret, err := models.GetIPsLast(ctx, cfg, interval)
|
||||||
|
return JSONResult(c, err, ret)
|
||||||
|
})
|
||||||
|
e.GET("/ips/last", func(c echo.Context) (err error) {
|
||||||
|
interval := "10 minutes"
|
||||||
|
ret, err := models.GetIPsLast(ctx, cfg, interval)
|
||||||
return JSONResult(c, err, ret)
|
return JSONResult(c, err, ret)
|
||||||
})
|
})
|
||||||
e.POST("/ips", func(c echo.Context) (err error) {
|
e.POST("/ips", func(c echo.Context) (err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user