(ctx context.Context, fromRepoID int64, currentUser string)
| 561 | } |
| 562 | |
| 563 | func (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 | |
| 607 | func 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 |
no test coverage detected