diff --git a/pkg/database/alerts.go b/pkg/database/alerts.go index 5559cbb39..c3957d31c 100644 --- a/pkg/database/alerts.go +++ b/pkg/database/alerts.go @@ -795,6 +795,13 @@ func (c *Client) CreateAlert(machineID string, alertList []*models.Alert) ([]str alertIDs = append(alertIDs, ids...) } + if owner != nil { + err = owner.Update().SetLastPush(time.Now().UTC()).Exec(c.CTX) + if err != nil { + return nil, fmt.Errorf("machine '%s': %w", machineID, err) + } + } + return alertIDs, nil } diff --git a/pkg/database/machines.go b/pkg/database/machines.go index b9834e57e..7a64c1d4d 100644 --- a/pkg/database/machines.go +++ b/pkg/database/machines.go @@ -134,14 +134,6 @@ func (c *Client) BulkDeleteWatchers(machines []*ent.Machine) (int, error) { return nbDeleted, nil } -func (c *Client) UpdateMachineLastPush(machineID string) error { - _, err := c.Ent.Machine.Update().Where(machine.MachineIdEQ(machineID)).SetLastPush(time.Now().UTC()).Save(c.CTX) - if err != nil { - return errors.Wrapf(UpdateFail, "updating machine last_push: %s", err) - } - return nil -} - func (c *Client) UpdateMachineLastHeartBeat(machineID string) error { _, err := c.Ent.Machine.Update().Where(machine.MachineIdEQ(machineID)).SetLastHeartbeat(time.Now().UTC()).Save(c.CTX) if err != nil {