This commit is contained in:
shoopea 2019-05-11 15:01:24 +08:00
parent 520f0cea14
commit 0e471b2e5d
2 changed files with 5 additions and 1 deletions

4
sql.go
View File

@ -1227,7 +1227,9 @@ func resetMsgParsingRules() {
func putUnprocessedMsg(m ChatWarsMessage) (int64, error) {
res, err := db.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
VALUES (` + strconv.Itoa(objTypeMessage) + `,` + strconv.Itoa(objSubTypeMessageUnknown) + `);`)
logOnError(err, "putUnprocessedMsg : exec insert obj")
if err != nil {
return 0, err
}
@ -1238,12 +1240,14 @@ func putUnprocessedMsg(m ChatWarsMessage) (int64, error) {
stmt, err := db.Prepare(`INSERT INTO obj_msg (obj_id, msg_id, chat_id, user_id, sender_user_id, date, text)
VALUES (?, ?, ?, ?, ?, ?, ?);`)
logOnError(err, "putUnprocessedMsg : prepare insert obj_msg")
if err != nil {
return 0, err
}
defer stmt.Close()
_, err = stmt.Exec(objId, m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
logOnError(err, "putUnprocessedMsg : exec insert obj_msg")
if err != nil {
return 0, err
}

View File

@ -58,7 +58,7 @@ func SQLCWMsgWorker(id int, msgs <-chan ChatWarsMessage, objIds chan<- int64) {
for m := range msgs {
objId, err := putUnprocessedMsg(m)
logOnError(err, "SQLCWMsgWorker["+strconv.Itoa(id)+"] : Inserting message.")
if err == nil {
if err == nil && objId != 0 {
// log.Printf("SQLCWMsgWorker["+strconv.Itoa(id)+"] : Message inserted (%d).\n", objId)
objIds <- objId
}