Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fetch insight and insight repositories in parallel #79

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading