Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Commit e367547

Browse files
fix: fetch insight and insight repositories in parallel (#79)
1 parent 310d4b4 commit e367547

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/github/entities/db-insight.entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface DbInsight {
1010
repos: DbUserInsightRepo[];
1111
}
1212

13-
interface DbUserInsightRepo {
13+
export interface DbUserInsightRepo {
1414
readonly id: number;
1515
readonly insight_id: number;
1616
readonly repo_id: number;

src/social-card/insight-card/insight-card.service.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import tailwindConfig from "../templates/tailwind.config";
99
import { firstValueFrom } from "rxjs";
1010

1111
import { RequiresUpdateMeta } from "../user-card/user-card.service";
12-
import { DbInsight } from "../../github/entities/db-insight.entity";
12+
import { DbInsight, DbUserInsightRepo } from "../../github/entities/db-insight.entity";
1313
import insightCardTemplate from "../templates/insight-card.template";
1414
import insightRepos from "../templates/shared/insight-repos";
1515
import insightContributors from "../templates/shared/insight-contributors";
@@ -34,12 +34,16 @@ export class InsightCardService {
3434
private async getInsightData (insightId: number): Promise<InsightCardData> {
3535
const maxRepoQueryIdsLenght = 10;
3636

37-
const insightPageReq = await firstValueFrom(
38-
this.httpService.get<DbInsight>(`${process.env.API_BASE_URL!}/v2/insights/${insightId}`),
37+
const insightPageApiReq = firstValueFrom(
38+
this.httpService.get<DbInsight>(`${process.env.API_BASE_URL!}/v2/insights/${insightId}?include=none`),
3939
);
40+
const insightReposApiReq = firstValueFrom(
41+
this.httpService.get<DbUserInsightRepo[]>(`${process.env.API_BASE_URL!}/v2/insights/${insightId}/repos`),
42+
);
43+
const [insightPageReq, insightReposReq] = await Promise.all([insightPageApiReq, insightReposApiReq]);
4044

41-
const { repos, name, updated_at } = insightPageReq.data;
42-
45+
const { name, updated_at } = insightPageReq.data;
46+
const { data: repos } = insightReposReq;
4347
const query = (new URLSearchParams);
4448

4549
query.set(

0 commit comments

Comments
 (0)