update last_push on AlertCreate
This commit is contained in:
parent
45df3c9526
commit
3046181316
|
@ -126,6 +126,11 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := c.DBClient.UpdateMachineLastPush(machineID); err != nil {
|
||||||
|
c.HandleDBErrors(gctx, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, alert := range input {
|
for _, alert := range input {
|
||||||
alert.MachineID = machineID
|
alert.MachineID = machineID
|
||||||
for pIdx, profile := range c.Profiles {
|
for pIdx, profile := range c.Profiles {
|
||||||
|
|
|
@ -107,6 +107,14 @@ func (c *Client) DeleteWatcher(name string) error {
|
||||||
return nil
|
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 {
|
func (c *Client) UpdateMachineScenarios(scenarios string, ID int) error {
|
||||||
_, err := c.Ent.Machine.UpdateOneID(ID).
|
_, err := c.Ent.Machine.UpdateOneID(ID).
|
||||||
SetUpdatedAt(time.Now()).
|
SetUpdatedAt(time.Now()).
|
||||||
|
|
Loading…
Reference in a new issue