mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 10:48:15 +08:00
[REV] optimize event update method
This commit is contained in:
parent
9844ae172a
commit
6d5532adb6
@ -26,6 +26,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
|
||||
@ -53,6 +55,8 @@ func (c *EventDaoImpl) UpdateModel(mo model.Interface) error {
|
||||
var oldResult model.ServiceEvent
|
||||
if ok := c.DB.Where("event_id=?", result.EventID).Find(&oldResult).RecordNotFound(); !ok {
|
||||
finalUpdateEvent(result,&oldResult)
|
||||
oldB,_:=json.Marshal(oldResult)
|
||||
logrus.Infof("update event to %s",string(oldB))
|
||||
if err := c.DB.Save(oldResult).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
@ -62,22 +66,21 @@ func (c *EventDaoImpl) UpdateModel(mo model.Interface) error {
|
||||
func finalUpdateEvent(target *model.ServiceEvent, old *model.ServiceEvent) {
|
||||
if target.CodeVersion!="" {
|
||||
old.CodeVersion=target.CodeVersion
|
||||
}else{
|
||||
if target.Status!="" {
|
||||
old.Status=target.Status
|
||||
}
|
||||
if target.Message!="" {
|
||||
old.Message=target.Message
|
||||
}
|
||||
old.FinalStatus = "complete"
|
||||
if target.FinalStatus!="" {
|
||||
old.FinalStatus=target.FinalStatus
|
||||
}
|
||||
}
|
||||
if target.Status!="" {
|
||||
old.Status=target.Status
|
||||
}
|
||||
if target.Message!="" {
|
||||
old.Message=target.Message
|
||||
}
|
||||
old.FinalStatus = "complete"
|
||||
if target.FinalStatus!="" {
|
||||
old.FinalStatus=target.FinalStatus
|
||||
}
|
||||
|
||||
old.EndTime = time.Now().String()
|
||||
if old.Status == "failure" && old.OptType == "callback"{
|
||||
old.DeployVersion = old.OldDeployVersion
|
||||
}
|
||||
old.EndTime = time.Now().String()
|
||||
if old.Status == "failure" && old.OptType == "callback"{
|
||||
old.DeployVersion = old.OldDeployVersion
|
||||
}
|
||||
}
|
||||
//EventLogMessageDaoImpl EventLogMessageDaoImpl
|
||||
|
Loading…
Reference in New Issue
Block a user