From ea09905151b552da4a9d4eb2037c9b9ee88ab9be Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 12 Feb 2022 11:43:45 +0100 Subject: [PATCH] added groupby to http://host/ip/last endpoint --- src/models/ip.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/models/ip.go b/src/models/ip.go index 42a477a..cb5a0d8 100644 --- a/src/models/ip.go +++ b/src/models/ip.go @@ -27,7 +27,7 @@ func GetIPs(ctx *context.Context, config *config.Config, limit int) (apimailboxe // GetIPs ... func GetIPsLast(ctx *context.Context, config *config.Config, interval string) (apimailboxes []*api.IP, err error) { 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 { apimailboxes = append(apimailboxes, ml.APIFormat()) } @@ -120,7 +120,6 @@ func (ip *IP) APIFormat() *api.IP { return nil } return &api.IP{ - ID: ip.ID, IP: ip.IP, Rdns: ip.Rdns.String, Src: ip.Src,