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

Method Sort

module/ai-key/iml.go:420–447  ·  view source on GitHub ↗
(ctx context.Context, providerId string, input *ai_key_dto.Sort)

Source from the content-addressed store, hash-verified

418}
419
420func (i *imlKeyModule) Sort(ctx context.Context, providerId string, input *ai_key_dto.Sort) error {
421 _, err := i.providerService.Get(ctx, providerId)
422 if err != nil {
423 return fmt.Errorf("provider not found: %w", err)
424 }
425 return i.transaction.Transaction(ctx, func(ctx context.Context) error {
426 switch input.Sort {
427 case "before":
428 _, err = i.aiKeyService.SortBefore(ctx, providerId, input.Origin, input.Target)
429 case "after":
430 _, err = i.aiKeyService.SortAfter(ctx, providerId, input.Origin, input.Target)
431 default:
432 return fmt.Errorf("invalid sort type: %s", input.Sort)
433 }
434 if err != nil {
435 return err
436 }
437 list, err := i.aiKeyService.KeysByProvider(ctx, providerId)
438 if err != nil {
439 return err
440 }
441 releases := make([]*gateway.DynamicRelease, 0, len(list))
442 for _, info := range list {
443 releases = append(releases, newKey(info))
444 }
445 return i.syncGateway(ctx, cluster.DefaultClusterID, releases, true)
446 })
447}

Callers

nothing calls this directly

Calls 6

syncGatewayMethod · 0.95
newKeyFunction · 0.70
GetMethod · 0.65
SortBeforeMethod · 0.65
SortAfterMethod · 0.65
KeysByProviderMethod · 0.65

Tested by

no test coverage detected