update last_push on AlertCreate

This commit is contained in:
bui 2021-10-08 15:54:37 +02:00 committed by alteredCoder
parent 45df3c9526
commit 3046181316
2 changed files with 13 additions and 0 deletions

View file

@ -126,6 +126,11 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
return
}
if err := c.DBClient.UpdateMachineLastPush(machineID); err != nil {
c.HandleDBErrors(gctx, err)
return
}
for _, alert := range input {
alert.MachineID = machineID
for pIdx, profile := range c.Profiles {

View file

@ -107,6 +107,14 @@ func (c *Client) DeleteWatcher(name string) error {
return nil
}
func (c *Client) UpdateMachineLastPush(machineID string) error {
_, err := c.Ent.Machine.Update().Where(machine.MachineIdEQ(machineID)).SetLastPush(time.Now()).Save(c.CTX)
if err != nil {
return errors.Wrapf(UpdateFail, "updating machine last_push: %s", err)
}
return nil
}
func (c *Client) UpdateMachineScenarios(scenarios string, ID int) error {
_, err := c.Ent.Machine.UpdateOneID(ID).
SetUpdatedAt(time.Now()).