From 3a45e3f595216e90afd04771b9b49e61b66a4e56 Mon Sep 17 00:00:00 2001 From: shoopea Date: Mon, 3 Jun 2019 09:40:37 +0800 Subject: [PATCH] test --- items.go | 2 +- obj.go | 21 +++++++++++++-------- workers.go | 2 -- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/items.go b/items.go index 04a14be..b5e8ba3 100644 --- a/items.go +++ b/items.go @@ -5,7 +5,7 @@ import ( ) func reloadObjItem(code string, name string, itemTypeID64 int64, weight int) { - id := getObjItemID(code, name) + id := silentGetObjItemID(code, name) if id == 0 { _, err := addObjItem(code, name, itemTypeID64, weight) logOnError(err, "reloadObjItem : addObjItem") diff --git a/obj.go b/obj.go index 62add67..dedebc7 100644 --- a/obj.go +++ b/obj.go @@ -500,18 +500,23 @@ func addObjItem(code string, name string, itemTypeID64 int64, weight int) (int64 } func getObjItemID(c string, n string) int64 { + i := silentGetObjItemID(c, n) + if i == 0 { + w := TGCommand{ + Type: commandSendMsg, + Text: fmt.Sprintf("Object unknown : %s - %s\n", c, n), + ToUserID64: cfg.Bot.Admin, + } + TGCmdQueue <- w + } + return i +} + +func silentGetObjItemID(c string, n string) int64 { if v, ok := cacheObjItem.Load(c); ok { i := v.(ChatWarsItem) return i.ObjID64 } else { - /* - w := TGCommand{ - Type: commandSendMsg, - Text: fmt.Sprintf("Object unknown : %s - %s\n", c, n), - ToUserID64: cfg.Bot.Admin, - } - TGCmdQueue <- w - */ return 0 } } diff --git a/workers.go b/workers.go index 0fdfc11..ba8b858 100644 --- a/workers.go +++ b/workers.go @@ -220,8 +220,6 @@ func SQLJobWorker() { } if len(jobs) < SQLJobSliceSize { time.Sleep(100 * time.Millisecond) - } else { - time.Sleep(1 * time.Millisecond) } } log.Printf("SQLJobWorker : Closing.")