This commit is contained in:
shoopea 2020-10-17 11:12:01 +02:00
parent ac4bf679ec
commit 51b2c3ffbe
2 changed files with 29 additions and 2 deletions

4
def.go
View File

@ -108,7 +108,8 @@ type ChirpConfig struct {
type ChirpClient struct { type ChirpClient struct {
HeartBeat time.Time `json:"heart_beat"` HeartBeat time.Time `json:"heart_beat"`
Login string `json:"nickname"` Login string `json:"login"`
Nickname string `json:"nickname"`
Build string `json:"build"` Build string `json:"build"`
Active bool `json:"active"` Active bool `json:"active"`
TGUserID64 int64 `json:"tg_user_id"` TGUserID64 int64 `json:"tg_user_id"`
@ -118,6 +119,7 @@ type ChirpClient struct {
CWRole string `json:"role"` CWRole string `json:"role"`
CWState string `json:"state"` CWState string `json:"state"`
CWClass string `json:"class"` CWClass string `json:"class"`
CWClass2 string `json:"class2"`
CWBusyUntil time.Time `json:"busy_until"` CWBusyUntil time.Time `json:"busy_until"`
CWLastUpdate time.Time `json:"last_update"` CWLastUpdate time.Time `json:"last_update"`
CWIdle bool `json:"game_idle"` CWIdle bool `json:"game_idle"`

27
sql.go
View File

@ -972,14 +972,38 @@ func cleanupJobData() {
jobStmt.Close() jobStmt.Close()
return return
} }
defer jobStmt.Close()
jobs, err := jobStmt.Query() jobs, err := jobStmt.Query()
logOnError(err, "cleanupJobData : query jobStmt") logOnError(err, "cleanupJobData : query jobStmt")
if err != nil { if err != nil {
jobStmt.Close()
return return
} }
doneStmt, err := db.Prepare(`SELECT oj.is_done FROM obj_job oj WHERE oj.obj_id = ?;`)
logOnError(err, "cleanupJobData : prepare doneStmt")
if err != nil {
doneStmt.Close()
return
}
defer doneStmt.Close()
delJobStmt, err := db.Prepare(`DELETE FROM obj_job WHERE obj_id = ?;`)
logOnError(err, "cleanupJobData : prepare delJobStmt")
if err != nil {
delJobStmt.Close()
return
}
defer delJobStmt.Close()
delObjStmt, err := db.Prepare(`DELETE FROM obj WHERE id = ?;`)
logOnError(err, "cleanupJobData : prepare delObjStmt")
if err != nil {
delObjStmt.Close()
return
}
defer delObjStmt.Close()
for jobs.Next() { for jobs.Next() {
err = jobs.Scan(&jobID) err = jobs.Scan(&jobID)
logOnError(err, "cleanupJobData : scan jobStmt") logOnError(err, "cleanupJobData : scan jobStmt")
@ -987,6 +1011,7 @@ func cleanupJobData() {
return return
} }
log.Printf("cleanupJobData : JobID : %d\n", jobID) log.Printf("cleanupJobData : JobID : %d\n", jobID)
count += 1 count += 1
} }