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

27
sql.go
View File

@ -972,14 +972,38 @@ func cleanupJobData() {
jobStmt.Close()
return
}
defer jobStmt.Close()
jobs, err := jobStmt.Query()
logOnError(err, "cleanupJobData : query jobStmt")
if err != nil {
jobStmt.Close()
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() {
err = jobs.Scan(&jobID)
logOnError(err, "cleanupJobData : scan jobStmt")
@ -987,6 +1011,7 @@ func cleanupJobData() {
return
}
log.Printf("cleanupJobData : JobID : %d\n", jobID)
count += 1
}