1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-10-10 01:13:40 +08:00
parent 2b4b3e16b2
commit b3024262ca
6 changed files with 32 additions and 27 deletions

25
meta.go
View File

@ -367,7 +367,9 @@ func (m *Message) Options(arg ...Any) *Message {
return m
}
func (m *Message) Optionv(key string, arg ...Any) Any {
var unlock func()
if len(arg) > 0 {
unlock = m.lock.Lock()
kit.If(kit.IndexOf(m.meta[MSG_OPTION], key) == -1, func() { m.meta[MSG_OPTION] = append(m.meta[MSG_OPTION], key) })
switch delete(m.data, key); v := arg[0].(type) {
case nil:
@ -379,16 +381,23 @@ func (m *Message) Optionv(key string, arg ...Any) Any {
default:
m.data[key] = v
}
} else {
unlock = m.lock.RLock()
}
for msg := m; msg != nil; msg = msg.message {
if v, ok := msg.data[key]; ok {
return v
}
if v, ok := msg.meta[key]; ok {
return v
}
if v, ok := m.data[key]; ok {
unlock()
return v
} else if v, ok := m.meta[key]; ok {
unlock()
return v
} else {
unlock()
}
if m.message != nil {
return m.message.Optionv(key)
} else {
return nil
}
return nil
}
func (m *Message) Option(key string, arg ...Any) string {
return kit.Select("", kit.Simple(m.Optionv(key, arg...)), 0)

View File

@ -45,9 +45,9 @@ field "状态机" web.code.git.status
field "配置键" web.code.git.configs
field "服务器" web.code.git.service
field "代码源" web.code.git.search args `repos`
return
field "架构图" web.code.git.spide args `icebergs`
field "趋势图" web.code.git.trend args `icebergs`
return
field "代码行" web.code.git.count
field "统计量" web.code.git.total
@ -58,7 +58,6 @@ service.go
search.go
search.js
search.css
search.shy
spide.go
trend.go

View File

@ -2,11 +2,8 @@ package git
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
kit "shylinux.com/x/toolkits"
)
const SPIDE = "spide"
@ -14,12 +11,11 @@ const SPIDE = "spide"
func init() {
Index.MergeCommands(ice.Commands{
SPIDE: {Name: "spide repos auto", Help: "构架图", Hand: func(m *ice.Message, arg ...string) {
if len(kit.Slice(arg, 0, 1)) == 0 {
if len(arg) == 0 {
m.Cmdy(REPOS)
} else if len(arg) == 1 {
nfs.DirDeepAll(m, _repos_path(m, arg[0]), "", func(value ice.Maps) { m.Push("", value, []string{nfs.PATH}) }, nfs.PATH)
m.Options(nfs.DIR_ROOT, _repos_path(m, arg[0])+nfs.PS).StatusTimeCount()
ctx.DisplayStory(m, "", mdb.FIELD, nfs.PATH, aaa.ROOT, arg[0])
} else if p := _repos_path(m, arg[0]); len(arg) == 1 {
nfs.DirDeepAll(m, p, "", nil, nfs.PATH).Options(nfs.DIR_ROOT, p+nfs.PS)
ctx.DisplayStory(m, "")
}
}},
})

View File

@ -29,7 +29,7 @@ func init() {
REST = "rest"
)
Index.MergeCommands(ice.Commands{
TOTAL: {Name: "total repos auto pie", Help: "统计量", Actions: ice.MergeActions(ice.Actions{
TOTAL: {Name: "total repos auto pie", Help: "统计量", Actions: ice.Actions{
"pie": {Help: "饼图", Hand: func(m *ice.Message, arg ...string) {
defer ctx.DisplayStory(m, "pie.js")
m.Cmd("", func(value ice.Maps) {
@ -38,9 +38,9 @@ func init() {
})
})
}},
}, ctx.ConfAction("skip", kit.DictList("go-git", "go-qrcode", "websocket", "webview", "word-dict"))), Hand: func(m *ice.Message, arg ...string) {
}, Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 0 {
ReposList(m).Table(func(value ice.Maps) {
ReposList(m.Spawn()).Table(func(value ice.Maps) {
kit.If(value[REPOS] == arg[0], func() { m.Cmdy("_sum", value[nfs.PATH], arg[1:]) })
})
m.StatusTimeCount(m.AppendSimple(FROM))
@ -48,9 +48,6 @@ func init() {
}
from, days, commit, adds, dels, rest := "", 0, 0, 0, 0, 0
TableGo(ReposList(m), func(value ice.Maps, lock *task.Lock) {
if mdb.Config(m, kit.Keys("skip", value[REPOS])) == ice.TRUE {
return
}
msg := m.Cmd("_sum", value[nfs.PATH], mdb.TOTAL, "10000")
defer lock.Lock()()
msg.Table(func(value ice.Maps) {
@ -66,6 +63,8 @@ func init() {
m.SortIntR(REST).StatusTimeCount()
}},
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计量", Hand: func(m *ice.Message, arg ...string) {
m.Options(nfs.CAT_CONTENT, "")
m.Options(nfs.DIR_ROOT, "")
if len(arg) > 0 {
if nfs.Exists(m, _git_dir(arg[0])) || nfs.Exists(m, path.Join(arg[0], "refs/heads/")) {
m.Option(cli.CMD_DIR, arg[0])

View File

@ -5,6 +5,7 @@ import (
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web/html"
"shylinux.com/x/icebergs/core/code"
kit "shylinux.com/x/toolkits"
)
@ -13,14 +14,13 @@ const TREND = "trend"
func init() {
Index.MergeCommands(ice.Commands{
TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Actions: ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, ice.OptionFields("repos,time")) }},
TREND: {Name: "trend repos begin_time@date auto", Help: "趋势图", Actions: ice.Actions{
mdb.DETAIL: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy("", code.INNER, m.Option(REPOS), MASTER, m.Option(mdb.HASH), m.Cmdv(REPOS, m.Option(REPOS), MASTER, m.Option(mdb.HASH), nfs.FILE))
}},
code.INNER: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(REPOS, code.INNER, arg)
ctx.DisplayLocal(m, "code/inner.js", "style", "float")
ctx.DisplayLocal(m, "code/inner.js", ctx.STYLE, html.FLOAT)
}},
}, Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 {

View File

@ -10,6 +10,7 @@ import (
kit "shylinux.com/x/toolkits"
"shylinux.com/x/toolkits/logs"
"shylinux.com/x/toolkits/task"
)
type Any = interface{}
@ -212,6 +213,7 @@ type Message struct {
data Map
meta map[string][]string
lock task.Lock
root *Message
message *Message