({
where,
take,
}: {
where?: Prisma.RepoWhereInput,
take?: number
} = {})
| 189 | })); |
| 190 | |
| 191 | export const getRepos = async ({ |
| 192 | where, |
| 193 | take, |
| 194 | }: { |
| 195 | where?: Prisma.RepoWhereInput, |
| 196 | take?: number |
| 197 | } = {}) => sew(() => |
| 198 | withOptionalAuth(async ({ org, prisma }) => { |
| 199 | const repos = await prisma.repo.findMany({ |
| 200 | where: { |
| 201 | orgId: org.id, |
| 202 | ...where, |
| 203 | }, |
| 204 | take, |
| 205 | }); |
| 206 | |
| 207 | const baseUrl = env.AUTH_URL; |
| 208 | |
| 209 | return repos.map((repo) => ({ |
| 210 | codeHostType: repo.external_codeHostType, |
| 211 | repoId: repo.id, |
| 212 | repoName: repo.name, |
| 213 | repoDisplayName: repo.displayName ?? undefined, |
| 214 | webUrl: `${baseUrl}${getBrowsePath({ |
| 215 | repoName: repo.name, |
| 216 | path: '', |
| 217 | pathType: 'tree', |
| 218 | })}`, |
| 219 | externalWebUrl: repo.webUrl ?? undefined, |
| 220 | imageUrl: repo.imageUrl ?? undefined, |
| 221 | indexedAt: repo.indexedAt ?? undefined, |
| 222 | pushedAt: repo.pushedAt ?? undefined, |
| 223 | defaultBranch: repo.defaultBranch ?? undefined, |
| 224 | isFork: repo.isFork, |
| 225 | isArchived: repo.isArchived, |
| 226 | } satisfies RepositoryQuery)) |
| 227 | })); |
| 228 | |
| 229 | /** |
| 230 | * Returns a set of aggregated stats about the repos in the org |
no test coverage detected