diff --git a/base/cli/runtime.go b/base/cli/runtime.go index f13352ec..435b6d00 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -44,8 +44,8 @@ func _runtime_init(m *ice.Message) { ice.Info.Pathname = m.Conf(RUNTIME, kit.Keys(BOOT, PATHNAME)) ice.Info.Username = m.Conf(RUNTIME, kit.Keys(BOOT, USERNAME)) ice.Info.System = m.Conf(RUNTIME, kit.Keys(HOST, OSID)) - aaa.UserRoot(ice.Pulse, "", ice.Info.Username, aaa.ROOT, ice.OPS) aaa.UserRoot(ice.Pulse, "", ice.Info.Make.Username, aaa.TECH, ice.DEV) + aaa.UserRoot(ice.Pulse, "", ice.Info.Username, aaa.ROOT, ice.OPS) if runtime.GOARCH != MIPSLE { msg := m.Cmd(nfs.DIR, _system_find(m, os.Args[0]), "time,path,size,hash") m.Conf(RUNTIME, kit.Keys(BOOT, mdb.TIME), msg.Append(mdb.TIME)) diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index b6f7d52c..b4185175 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -93,6 +93,7 @@ const ( FSIZE = kit.MDB_FSIZE ICONS = "icons" + UNITS = "units" TOOLS = "tools" SOURCE = "_source" TARGET = "_target" diff --git a/base/web/dream.go b/base/web/dream.go index e136f277..fca3ab7a 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -46,12 +46,7 @@ func _dream_list(m *ice.Message) *ice.Message { } } }) - mem, disk := 0, 0 - PushPodCmd(m.Spawn(), ROUTE, "travel").Table(func(value ice.Maps) { - mem += kit.Int(kit.Select("", kit.Split(value[nfs.SIZE], nfs.PS), 0)) - disk += kit.Int(kit.Select("", kit.Split(value[nfs.SIZE], nfs.PS), 2)) - }) - return m.Sort("status,type,name", ice.STR, ice.STR, ice.STR_R).StatusTimeCount(stats, nfs.SIZE, kit.Format("%s/%s", kit.FmtSize(mem), kit.FmtSize(disk))) + return m.Sort("status,type,name", ice.STR, ice.STR, ice.STR_R).StatusTimeCount() } func _dream_start(m *ice.Message, name string) { @@ -260,10 +255,8 @@ func init() { stats[cli.START]++ } }) - m.Push(mdb.NAME, kit.Keys(m.CommandKey(), cli.START)).Push(mdb.VALUE, stats[cli.START]) - m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.TOTAL)).Push(mdb.VALUE, msg.Length()) - m.Push("units", "") - m.Push("units", "") + PushStats(m, kit.Keys(m.CommandKey(), cli.START), stats[cli.START], "") + PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "") } }}, }, aaa.RoleAction(), StatsAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, "web.space,web.route,web.code.git.search", mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) { diff --git a/base/web/stats.go b/base/web/stats.go index df4e8718..a46a4d7a 100644 --- a/base/web/stats.go +++ b/base/web/stats.go @@ -17,8 +17,9 @@ const STATS = "stats" func init() { Index.MergeCommands(ice.Commands{ - STATS: {Name: "stats name auto", Help: "汇总量", Meta: kit.Dict( + STATS: {Name: "stats refresh", Help: "汇总量", Meta: kit.Dict( ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict( + "command.total", "命令总数", "repos.total", "代码库总数", "dream.total", "空间总数", "dream.start", "已启动空间", @@ -36,11 +37,16 @@ func init() { "cpu.total", "处理器核数", )), ), Hand: func(m *ice.Message, arg ...string) { - m.Push(mdb.NAME, kit.Keys(aaa.SESS, mdb.TOTAL)).Push(mdb.VALUE, m.Cmd(aaa.SESS).Length()) - m.Push(mdb.NAME, kit.Keys(aaa.USER, mdb.TOTAL)).Push(mdb.VALUE, m.Cmd(aaa.USER).Length()-1) - m.Push("units", "") - m.Push("units", "") - ctx.DisplayStory(m, "stats.js") + defer ctx.DisplayStory(m, "stats.js") + if m.Option(ice.MSG_USERPOD) == "" { + PushStats(m, kit.Keys(aaa.SESS, mdb.TOTAL), m.Cmd(aaa.SESS).Length(), "") + if ice.Info.Username == ice.Info.Make.Username { + PushStats(m, kit.Keys(aaa.USER, mdb.TOTAL), m.Cmd(aaa.USER).Length()-1, "") + } else { + PushStats(m, kit.Keys(aaa.USER, mdb.TOTAL), m.Cmd(aaa.USER).Length()-2, "") + } + PushStats(m, kit.Keys(ctx.COMMAND, mdb.TOTAL), m.Cmd(ctx.COMMAND).Length(), "") + } gdb.Event(m, STATS_TABLES) PushPodCmd(m, "", arg...) }}, @@ -50,9 +56,11 @@ func StatsAction() ice.Actions { return ice.MergeActions(ice.Actions{ STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) { if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 { - m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.TOTAL)).Push(mdb.VALUE, msg.Length()) - m.Push("units", "") + PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "") } }}, }, gdb.EventsAction(STATS_TABLES)) } +func PushStats(m *ice.Message, name string, value ice.Any, units string) { + kit.If(value != 0, func() { m.Push(mdb.NAME, name).Push(mdb.VALUE, value).Push(mdb.UNITS, units) }) +} diff --git a/core/code/autogen.go b/core/code/autogen.go index 4f8d73eb..5c3f1712 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -83,7 +83,7 @@ func _autogen_gits(m *ice.Message, arg ...string) string { } func _autogen_git(m *ice.Message, arg ...string) ice.Map { msg := m.Cmd(REPOS, REMOTE) - return kit.Dict(arg, aaa.USERNAME, ice.Info.Username, tcp.HOSTNAME, ice.Info.Hostname, nfs.PATH, kit.Path("")+nfs.PS, mdb.TIME, m.Time(), + return kit.Dict(arg, aaa.USERNAME, m.Option(ice.MSG_USERNAME), tcp.HOSTNAME, ice.Info.Hostname, nfs.PATH, kit.Path("")+nfs.PS, mdb.TIME, m.Time(), GIT, GitVersion(m), GO, GoVersion(m), nfs.MODULE, _autogen_mod(m, ice.GO_MOD), msg.AppendSimple("remote,branch,version,forword,author,email,hash,when,message"), web.DOMAIN, strings.ReplaceAll(tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)), "%2F", nfs.PS), diff --git a/core/mall/goods.go b/core/mall/goods.go index c613c324..87d5857a 100644 --- a/core/mall/goods.go +++ b/core/mall/goods.go @@ -33,10 +33,8 @@ func init() { web.STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) { if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 { amount := msg.TableAmount(func(value ice.Maps) float64 { return kit.Float(value[mdb.COUNT]) * kit.Float(value[PRICE]) }) - m.Push(mdb.NAME, kit.Keys(m.CommandKey(), AMOUNT)).Push(mdb.VALUE, amount) - m.Push("units", "元") - m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.COUNT)).Push(mdb.VALUE, msg.Length()) - m.Push("units", "") + web.PushStats(m, kit.Keys(m.CommandKey(), AMOUNT), amount, "元") + web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "") } }}, }, aaa.RoleAction(), web.StatsAction(), web.ExportCacheAction(nfs.IMAGE), mdb.ExportHashAction(ctx.TOOLS, kit.Fields(Prefix(CART), Prefix(ORDER)), mdb.FIELD, "time,hash,zone,name,text,price,count,units,image")), Hand: func(m *ice.Message, arg ...string) { diff --git a/core/team/asset.go b/core/team/asset.go index e3058e73..0cdec784 100644 --- a/core/team/asset.go +++ b/core/team/asset.go @@ -101,10 +101,8 @@ func init() { web.STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) { if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 { amount := msg.TableAmount(func(value ice.Maps) float64 { return kit.Float(value[AMOUNT]) }) - m.Push(mdb.NAME, kit.Keys(m.CommandKey(), AMOUNT)).Push(mdb.VALUE, amount) - m.Push("units", "元") - m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.COUNT)).Push(mdb.VALUE, msg.Length()) - m.Push("units", "") + web.PushStats(m, kit.Keys(m.CommandKey(), AMOUNT), amount, "元") + web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "") } }}, }, web.StatsAction(), mdb.ExportZoneAction(mdb.SHORT, ACCOUNT, mdb.FIELD, "time,account,type,amount,count", mdb.FIELDS, "time,id,type,amount,name,text")), Hand: func(m *ice.Message, arg ...string) { diff --git a/core/team/task.go b/core/team/task.go index ceaaa280..32f33abb 100644 --- a/core/team/task.go +++ b/core/team/task.go @@ -101,8 +101,7 @@ func init() { if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 { count := 0 msg.Table(func(value ice.Maps) { count += kit.Int(value[mdb.COUNT]) }) - m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.TOTAL)).Push(mdb.VALUE, count) - m.Push("units", "") + web.PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), count, "") } }}, }, web.StatsAction(), mdb.ExportZoneAction(mdb.FIELD, "time,zone,count", mdb.FIELDS, "begin_time,end_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) {