(ctx context.Context, namespace string, repoPath string)
| 139 | } |
| 140 | |
| 141 | func (s *CodeStore) FindByPath(ctx context.Context, namespace string, repoPath string) (code *Code, err error) { |
| 142 | resCode := new(Code) |
| 143 | err = s.db.Operator.Core. |
| 144 | NewSelect(). |
| 145 | Model(resCode). |
| 146 | Relation("Repository.User"). |
| 147 | Where("repository.path =?", fmt.Sprintf("%s/%s", namespace, repoPath)). |
| 148 | Scan(ctx) |
| 149 | if err != nil { |
| 150 | return nil, fmt.Errorf("failed to find code: %w", err) |
| 151 | } |
| 152 | err = s.db.Operator.Core.NewSelect(). |
| 153 | Model(resCode.Repository). |
| 154 | WherePK(). |
| 155 | Relation("Tags", func(sq *bun.SelectQuery) *bun.SelectQuery { |
| 156 | return sq.Where("repository_tag.count > 0") |
| 157 | }). |
| 158 | Scan(ctx) |
| 159 | return resCode, err |
| 160 | } |
| 161 | |
| 162 | func (s *CodeStore) Delete(ctx context.Context, input Code) error { |
| 163 | res, err := s.db.Operator.Core.NewDelete().Model(&input).WherePK().Exec(ctx) |
no outgoing calls
no test coverage detected