()
| 230 | * Returns a set of aggregated stats about the repos in the org |
| 231 | */ |
| 232 | export const getReposStats = async () => sew(() => |
| 233 | withOptionalAuth(async ({ org, prisma }) => { |
| 234 | const [ |
| 235 | // Total number of repos. |
| 236 | numberOfRepos, |
| 237 | // Number of repos with their first time indexing jobs either |
| 238 | // pending or in progress. |
| 239 | numberOfReposWithFirstTimeIndexingJobsInProgress, |
| 240 | // Number of repos that have been indexed at least once. |
| 241 | numberOfReposWithIndex, |
| 242 | ] = await Promise.all([ |
| 243 | prisma.repo.count({ |
| 244 | where: { |
| 245 | orgId: org.id, |
| 246 | } |
| 247 | }), |
| 248 | prisma.repo.count({ |
| 249 | where: { |
| 250 | orgId: org.id, |
| 251 | indexedAt: null, |
| 252 | jobs: { |
| 253 | some: { |
| 254 | type: RepoIndexingJobType.INDEX, |
| 255 | status: { |
| 256 | in: [ |
| 257 | RepoIndexingJobStatus.PENDING, |
| 258 | RepoIndexingJobStatus.IN_PROGRESS, |
| 259 | ] |
| 260 | } |
| 261 | }, |
| 262 | }, |
| 263 | } |
| 264 | }), |
| 265 | prisma.repo.count({ |
| 266 | where: { |
| 267 | orgId: org.id, |
| 268 | NOT: { |
| 269 | indexedAt: null, |
| 270 | } |
| 271 | } |
| 272 | }) |
| 273 | ]); |
| 274 | |
| 275 | return { |
| 276 | numberOfRepos, |
| 277 | numberOfReposWithFirstTimeIndexingJobsInProgress, |
| 278 | numberOfReposWithIndex, |
| 279 | }; |
| 280 | }) |
| 281 | ) |
| 282 | |
| 283 | export const getConnectionStats = async () => sew(() => |
| 284 | withAuth(async ({ org, prisma }) => { |
no test coverage detected