MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / ToPublish

Method ToPublish

module/strategy/iml.go:133–162  ·  view source on GitHub ↗
(ctx context.Context, driver string)

Source from the content-addressed store, hash-verified

131}
132
133func (i *imlStrategyModule) ToPublish(ctx context.Context, driver string) ([]*strategy_dto.ToPublishItem, error) {
134 scope := strategy_dto.ToScope(strategy_dto.ScopeGlobal)
135 list, err := i.strategyService.SearchAllByDriver(ctx, "", driver, scope.Int(), "")
136 if err != nil {
137 return nil, err
138 }
139 strategyIds := utils.SliceToSlice(list, func(l *strategy.Strategy) string { return l.Id })
140 commits, err := i.strategyService.ListLatestStrategyCommit(ctx, scope.String(), "", strategyIds...)
141 if err != nil {
142 return nil, err
143 }
144 commitMap := utils.SliceToMapO(commits, func(c *commit.Commit[strategy.Commit]) (string, string) { return c.Data.Id, c.Data.Version })
145 items := make([]*strategy_dto.ToPublishItem, 0, len(list))
146 for _, l := range list {
147 status := strategy_dto.StrategyStatus(l, commitMap[l.Id])
148 if status == strategy_dto.PublishStatusOnline {
149 continue
150 }
151 items = append(items, &strategy_dto.ToPublishItem{
152 Name: l.Name,
153 Priority: l.Priority,
154 Status: status,
155 OptTime: l.UpdateAt,
156 })
157 }
158 sort.Slice(items, func(i, j int) bool {
159 return items[i].Priority < items[j].Priority
160 })
161 return items, nil
162}
163
164func (i *imlStrategyModule) Search(ctx context.Context, keyword string, driver string, scope strategy_dto.Scope, target string, page int, pageSize int, filters []string, order ...string) ([]*strategy_dto.StrategyItem, int64, error) {
165 list, total, err := i.strategyService.SearchByDriver(ctx, keyword, driver, scope.Int(), target, page, pageSize, filters, order...)

Callers

nothing calls this directly

Calls 4

SearchAllByDriverMethod · 0.65
IntMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected