added groupby to http://host/ip/last endpoint
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2022-02-12 11:43:45 +01:00
parent c759df10d0
commit ea09905151

View File

@ -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,