Handle shortening path
Opened this issue · 0 comments
github-actions commented
Handle shortening path
bntp.go/bntp/libtags/tagmanager.go
Line 428 in 6a10147
return
}
// FIX: hooks are processing the wrong values
func (m *TagManager) GetFromIDs(ctx context.Context, ids []int64) (records []*domain.Tag, err error) {
tags := []*domain.Tag{}
hookErr := goaoi.ForeachSlice(tags, m.Hooks.PartiallySpecializeExecuteHooks(ctx, bntp.BeforeAnyHook|bntp.BeforeSelectHook))
if hookErr != nil && !errors.Is(hookErr, goaoi.EmptyIterableError{}) {
hookErr = bntp.HookExecutionError{Inner: hookErr}
m.Logger.Error(hookErr)
}
records, err = m.Repository.GetFromIDs(ctx, ids)
if err != nil {
m.Logger.Error(err)
}
hookErr = goaoi.ForeachSlice(tags, m.Hooks.PartiallySpecializeExecuteHooks(ctx, bntp.AfterAnyHook|bntp.AfterSelectHook))
if hookErr != nil && !errors.Is(hookErr, goaoi.EmptyIterableError{}) {
hookErr = bntp.HookExecutionError{Inner: hookErr}
m.Logger.Error(hookErr)
}
return
}
// TODO: Handle shortening path
func (m *TagManager) MarshalPath(ctx context.Context, tag *domain.Tag, shorten bool) (path string, err error) {
if tag == nil {
err = helper.IneffectiveOperationError{helper.NilInputError{}}
return
}
parentPathTags := []*domain.Tag{}
hookErr := goaoi.ForeachSlice(parentPathTags, m.Hooks.PartiallySpecializeExecuteHooks(ctx, bntp.BeforeAnyHook|bntp.BeforeSelectHook))
if hookErr != nil && !errors.Is(hookErr, goaoi.EmptyIterableError{}) {
hookErr = bntp.HookExecutionError{Inner: hookErr}
m.Logger.Error(hookErr)
}
if len(tag.ParentPathIDs) == 0 {
return tag.Tag, nil
}
parentPathTags, err = m.Repository.GetFromIDs(ctx, tag.ParentPathIDs)
if err != nil {
m.Logger.Error(err)
} else {
pathTags := append(parentPathTags, tag)
tags, err := goaoi.TransformCopySliceUnsafe(pathTags, (*domain.Tag).GetTag)
if err != nil {
m.Logger.Error(err)
} else {
// Forming a tag path should be defined in a function
path = strings.Join(tags, "::")
}
}
hookErr = goaoi.ForeachSlice(parentPathTags, m.Hooks.PartiallySpecializeExecuteHooks(ctx, bntp.AfterAnyHook|bntp.AfterSelectHook))
if hookErr != nil && !errors.Is(hookErr, goaoi.EmptyIterableError{}) {
hookErr = bntp.HookExecutionError{Inner: hookErr}
m.Logger.Error(hookErr)
}
return
}
03ff6ece60425a2d0c1c7ee1347f454d02cec74d