fix
This commit is contained in:
parent
42a4f3e367
commit
496b26dd5c
13
sql.go
13
sql.go
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func initDB() {
|
||||
@ -170,24 +169,24 @@ func putUnprocessedMsg(m ChatWarsMessage) (int64, error) {
|
||||
res, err := db.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
|
||||
VALUES (3 , 1);`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
objId, err := res.LastInsertId()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
stmt, err := db.Prepare(`INSERT INTO obj_msg (obj_id, msg_id, chat_id, sender_user_id, date , text)
|
||||
VALUES (?, ?, ?, ?, FROM_UNIXTIME(?), ?);`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
_, err = stmt.Exec(objId, m.ID64, m.ChatID64, m.SenderUserID64, m.Date, m.Text)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return objId, nil
|
||||
@ -198,13 +197,13 @@ func getMsg(objId int64) (ChatWarsMessage, error) {
|
||||
|
||||
stmt, err := db.Prepare(`SELECT om.msg_id, om.chat_id, om.sender_user_id, UNIX_TIMESTAMP(om.date), om.text FROM obj_msg om WHERE om.id = ?`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return m, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
err = stmtOut.QueryRow(objId).Scan(&m.ID64, &m.ChatID64, &m.SenderUserID64, &m.Date, &m.Text)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return m, err
|
||||
}
|
||||
|
||||
return m, nil
|
||||
|
@ -74,7 +74,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
m, err := getMsg(objId)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving message.")
|
||||
if err == nil {
|
||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Message retrieved\n%s\n", m.text)
|
||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Message retrieved\n%s\n", m.Text)
|
||||
}
|
||||
}
|
||||
log.Printf("SQLIdentifyMsgWorker[" + strconv.Itoa(id) + "] : Closing.")
|
||||
|
Loading…
Reference in New Issue
Block a user