MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / getRelations

Method getRelations

component/model.go:563–605  ·  view source on GitHub ↗
(ctx context.Context, fromRepoID int64, currentUser string)

Source from the content-addressed store, hash-verified

561}
562
563func (c *ModelComponent) getRelations(ctx context.Context, fromRepoID int64, currentUser string) (*types.Relations, error) {
564 res, err := c.relatedRepos(ctx, fromRepoID, currentUser)
565 if err != nil {
566 return nil, err
567 }
568 rels := new(types.Relations)
569 datasetRepos := res[types.DatasetRepo]
570 for _, repo := range datasetRepos {
571 rels.Datasets = append(rels.Datasets, &types.Dataset{
572 Path: repo.Path,
573 Name: repo.Name,
574 Nickname: repo.Nickname,
575 Description: repo.Description,
576 UpdatedAt: repo.UpdatedAt,
577 Private: repo.Private,
578 Downloads: repo.DownloadCount,
579 })
580 }
581 codeRepos := res[types.CodeRepo]
582 for _, repo := range codeRepos {
583 rels.Codes = append(rels.Codes, &types.Code{
584 Path: repo.Path,
585 Name: repo.Name,
586 Nickname: repo.Nickname,
587 Description: repo.Description,
588 UpdatedAt: repo.UpdatedAt,
589 Private: repo.Private,
590 Downloads: repo.DownloadCount,
591 })
592 }
593 spaceRepos := res[types.SpaceRepo]
594 spacePaths := make([]string, 0)
595 for _, repo := range spaceRepos {
596 spacePaths = append(spacePaths, repo.Path)
597 }
598 spaces, err := c.spaceComonent.ListByPath(ctx, spacePaths)
599 if err != nil {
600 return nil, fmt.Errorf("failed to get space info by paths, error: %w", err)
601 }
602 rels.Spaces = spaces
603
604 return rels, nil
605}
606
607func getFilePaths(namespace, repoName, folder string, repoType types.RepositoryType, gsTree func(ctx context.Context, req gitserver.GetRepoInfoByPathReq) ([]*types.File, error)) ([]string, error) {
608 var filePaths []string

Callers 1

RelationsMethod · 0.95

Calls 2

relatedReposMethod · 0.80
ListByPathMethod · 0.45

Tested by

no test coverage detected