Skip to content

Commit

Permalink
fix: fetch insight and insight repositories in parallel (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts committed Feb 1, 2024
1 parent 310d4b4 commit e367547
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/github/entities/db-insight.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface DbInsight {
repos: DbUserInsightRepo[];
}

interface DbUserInsightRepo {
export interface DbUserInsightRepo {
readonly id: number;
readonly insight_id: number;
readonly repo_id: number;
Expand Down
14 changes: 9 additions & 5 deletions src/social-card/insight-card/insight-card.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import tailwindConfig from "../templates/tailwind.config";
import { firstValueFrom } from "rxjs";

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

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

const { repos, name, updated_at } = insightPageReq.data;

const { name, updated_at } = insightPageReq.data;
const { data: repos } = insightReposReq;
const query = (new URLSearchParams);

query.set(
Expand Down

0 comments on commit e367547

Please sign in to comment.