added groupby to http://host/ip/last endpoint
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c759df10d0
commit
ea09905151
@ -27,7 +27,7 @@ func GetIPs(ctx *context.Context, config *config.Config, limit int) (apimailboxe
|
|||||||
// GetIPs ...
|
// GetIPs ...
|
||||||
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)).Asc("id").Find(&ips)
|
err = config.Db.Where(fmt.Sprintf("updated >= (now()-'%s'::interval)", interval)).GroupBy("ip").Find(&ips)
|
||||||
for _, ml := range ips {
|
for _, ml := range ips {
|
||||||
apimailboxes = append(apimailboxes, ml.APIFormat())
|
apimailboxes = append(apimailboxes, ml.APIFormat())
|
||||||
}
|
}
|
||||||
@ -120,7 +120,6 @@ func (ip *IP) APIFormat() *api.IP {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &api.IP{
|
return &api.IP{
|
||||||
ID: ip.ID,
|
|
||||||
IP: ip.IP,
|
IP: ip.IP,
|
||||||
Rdns: ip.Rdns.String,
|
Rdns: ip.Rdns.String,
|
||||||
Src: ip.Src,
|
Src: ip.Src,
|
||||||
|
Loading…
Reference in New Issue
Block a user