|
| 1 | +import { AccountEntity } from "@dzcode.io/models/dist/account"; |
1 | 2 | import { Controller, Get } from "routing-controllers";
|
2 | 3 | import { OpenAPI, ResponseSchema } from "routing-controllers-openapi";
|
3 | 4 | import { DataService } from "src/data/service";
|
@@ -34,35 +35,34 @@ export class ProjectController {
|
34 | 35 | repositories: await Promise.all(
|
35 | 36 | repositories.map(async ({ provider, owner, repository }) => {
|
36 | 37 | let contributionCount = 0;
|
| 38 | + let contributors: AccountEntity[] = []; |
| 39 | + let languages: string[] = []; |
37 | 40 | try {
|
38 |
| - contributionCount = ( |
39 |
| - await this.githubService.listRepositoryIssues({ owner, repository }) |
40 |
| - ).length; |
| 41 | + [contributionCount, contributors, languages] = await Promise.all([ |
| 42 | + (await this.githubService.listRepositoryIssues({ owner, repository })).length, |
| 43 | + await Promise.all( |
| 44 | + ( |
| 45 | + await this.githubService.listRepositoryContributors({ owner, repository }) |
| 46 | + ).map(async ({ login }) => { |
| 47 | + const githubUser = await this.githubService.getUser({ username: login }); |
| 48 | + return this.githubService.githubUserToAccountEntity(githubUser); |
| 49 | + }), |
| 50 | + ), |
| 51 | + await this.githubService.listRepositoryLanguages({ owner, repository }), |
| 52 | + ]); |
41 | 53 | } catch (error) {
|
42 |
| - this.loggerService.warn({ |
43 |
| - message: `Failed to fetch contributionCount for ${owner}/${repository}: ${error}`, |
44 |
| - meta: { owner, repository }, |
| 54 | + this.loggerService.error({ |
| 55 | + message: `Failed to fetch rich info for project: ${owner}/${repository}`, |
| 56 | + meta: { owner, repository, error }, |
45 | 57 | });
|
46 | 58 | }
|
| 59 | + |
47 | 60 | return {
|
48 | 61 | provider,
|
49 | 62 | owner,
|
50 | 63 | repository,
|
51 |
| - stats: { |
52 |
| - contributionCount, |
53 |
| - languages: await this.githubService.listRepositoryLanguages({ |
54 |
| - owner, |
55 |
| - repository, |
56 |
| - }), |
57 |
| - }, |
58 |
| - contributors: await Promise.all( |
59 |
| - ( |
60 |
| - await this.githubService.listRepositoryContributors({ owner, repository }) |
61 |
| - ).map(async ({ login }) => { |
62 |
| - const githubUser = await this.githubService.getUser({ username: login }); |
63 |
| - return this.githubService.githubUserToAccountEntity(githubUser); |
64 |
| - }), |
65 |
| - ), |
| 64 | + stats: { contributionCount, languages }, |
| 65 | + contributors, |
66 | 66 | };
|
67 | 67 | }),
|
68 | 68 | ),
|
|
0 commit comments