test
This commit is contained in:
parent
019c680fe7
commit
99a89f5d86
2
def.go
2
def.go
@ -347,6 +347,8 @@ const (
|
|||||||
objSubTypeJobSetJobDone = 607
|
objSubTypeJobSetJobDone = 607
|
||||||
objSubTypeJobMsgClient = 608
|
objSubTypeJobMsgClient = 608
|
||||||
objSubTypeJobMsgRefresh = 609
|
objSubTypeJobMsgRefresh = 609
|
||||||
|
objSubTypeJobExportBackup = 610
|
||||||
|
objSubTypeJobImportBackup = 611
|
||||||
objSubTypeItemResource = 701
|
objSubTypeItemResource = 701
|
||||||
objSubTypeItemAlch = 702
|
objSubTypeItemAlch = 702
|
||||||
objSubTypeItemMisc = 703
|
objSubTypeItemMisc = 703
|
||||||
|
10
job.go
10
job.go
@ -38,7 +38,7 @@ func createJob(jobTypeID int32, priority int32, userID64 int64, schedule time.Ti
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
_, err = stmt.Exec(objId, priority, userID64, objJobStatusNew, schedule, time.Now(), payload)
|
_, err = stmt.Exec(objId, priority, userID64, objJobStatusNew, schedule.UTC(), time.Now().UTC(), payload)
|
||||||
logOnError(err, "createJob : insert obj_job")
|
logOnError(err, "createJob : insert obj_job")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -55,7 +55,7 @@ func setJobDone(jobId int64) error {
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
_, err = stmt.Exec(time.Now(), jobId)
|
_, err = stmt.Exec(time.Now().UTC(), jobId)
|
||||||
s := fmt.Sprintf("setJobDone, update obj_job(%d)", jobId)
|
s := fmt.Sprintf("setJobDone, update obj_job(%d)", jobId)
|
||||||
logOnError(err, s)
|
logOnError(err, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -72,7 +72,7 @@ func setJobStart(jobId int64) error {
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
_, err = stmt.Exec(time.Now(), jobId)
|
_, err = stmt.Exec(time.Now().UTC(), jobId)
|
||||||
s := fmt.Sprintf("setJobStart, update obj_job(%d)", jobId)
|
s := fmt.Sprintf("setJobStart, update obj_job(%d)", jobId)
|
||||||
logOnError(err, s)
|
logOnError(err, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -89,7 +89,7 @@ func rescheduleJob(jobID64 int64, status int32, schedule time.Time) error {
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
_, err = stmt.Exec(schedule, status, jobID64)
|
_, err = stmt.Exec(schedule.UTC(), status, jobID64)
|
||||||
s := fmt.Sprintf("rescheduleJob, update obj_job(%d)", jobID64)
|
s := fmt.Sprintf("rescheduleJob, update obj_job(%d)", jobID64)
|
||||||
logOnError(err, s)
|
logOnError(err, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -375,6 +375,8 @@ func jobMsgRefresh(j Job) {
|
|||||||
err = delObj(p.ObjID64)
|
err = delObj(p.ObjID64)
|
||||||
logOnError(err, "jobMsgRefresh : delObj")
|
logOnError(err, "jobMsgRefresh : delObj")
|
||||||
|
|
||||||
|
log.Printf("Refreshing message :\n%s\n", m.Text)
|
||||||
|
|
||||||
c := TGCommand{
|
c := TGCommand{
|
||||||
Type: commandRefreshMsg,
|
Type: commandRefreshMsg,
|
||||||
FromChatID64: m.ChatID64,
|
FromChatID64: m.ChatID64,
|
||||||
|
14
obj.go
14
obj.go
@ -75,7 +75,6 @@ func addObjMsg(msgID64 int64, msgChatID64 int64, msgUserID64 int64, msgSenderUse
|
|||||||
|
|
||||||
res, err := tx.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
|
res, err := tx.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
|
||||||
VALUES (` + strconv.Itoa(objTypeMessage) + `,` + strconv.Itoa(objSubTypeMessageUnknown) + `);`)
|
VALUES (` + strconv.Itoa(objTypeMessage) + `,` + strconv.Itoa(objSubTypeMessageUnknown) + `);`)
|
||||||
logOnError(err, "addObjMsg : exec insert obj")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err2 := tx.Rollback()
|
err2 := tx.Rollback()
|
||||||
logOnError(err2, "addObjMsg : rollback insert obj")
|
logOnError(err2, "addObjMsg : rollback insert obj")
|
||||||
@ -91,7 +90,6 @@ func addObjMsg(msgID64 int64, msgChatID64 int64, msgUserID64 int64, msgSenderUse
|
|||||||
|
|
||||||
stmt, err := tx.Prepare(`INSERT INTO obj_msg (obj_id, msg_id, chat_id, user_id, sender_user_id, date, text)
|
stmt, err := tx.Prepare(`INSERT INTO obj_msg (obj_id, msg_id, chat_id, user_id, sender_user_id, date, text)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?);`)
|
VALUES (?, ?, ?, ?, ?, ?, ?);`)
|
||||||
logOnError(err, "addObjMsg : prepare insert obj_msg")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err2 := tx.Rollback()
|
err2 := tx.Rollback()
|
||||||
logOnError(err2, "addObjMsg : rollback prepare insert obj_msg")
|
logOnError(err2, "addObjMsg : rollback prepare insert obj_msg")
|
||||||
@ -100,7 +98,6 @@ func addObjMsg(msgID64 int64, msgChatID64 int64, msgUserID64 int64, msgSenderUse
|
|||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
_, err = stmt.Exec(objId, msgID64, msgChatID64, msgUserID64, msgSenderUserID64, msgDate, msgText)
|
_, err = stmt.Exec(objId, msgID64, msgChatID64, msgUserID64, msgSenderUserID64, msgDate, msgText)
|
||||||
logOnError(err, "addObjMsg : exec insert obj_msg")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err2 := tx.Rollback()
|
err2 := tx.Rollback()
|
||||||
logOnError(err2, "addObjMsg : rollback exec insert obj_msg")
|
logOnError(err2, "addObjMsg : rollback exec insert obj_msg")
|
||||||
@ -108,7 +105,6 @@ func addObjMsg(msgID64 int64, msgChatID64 int64, msgUserID64 int64, msgSenderUse
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = tx.Commit()
|
err = tx.Commit()
|
||||||
logOnError(err, "addObjMsg : commit")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -168,6 +164,8 @@ func delObj(objId int64) error {
|
|||||||
return errors.New("Can only delete objSubTypeMessageAuctionAnnounce.")
|
return errors.New("Can only delete objSubTypeMessageAuctionAnnounce.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cacheObjMsg.Delete(objId) // better delete from cache before, worst case we reload after
|
||||||
|
|
||||||
stmt, err := db.Prepare(`DELETE FROM obj WHERE id = ?`)
|
stmt, err := db.Prepare(`DELETE FROM obj WHERE id = ?`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -184,9 +182,11 @@ func delObj(objId int64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("delObj : %d RowsAffected.\n", count)
|
if count > 1 {
|
||||||
|
return errors.New("More than one row impacted.")
|
||||||
cacheObjMsg.Delete(objId)
|
} else if count == 0 {
|
||||||
|
return errors.New("No row impacted.")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user