Skip to content

fix/242/github stadistics should return data by project id #243

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

Merged
merged 1 commit into from
Oct 12, 2023
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
4 changes: 2 additions & 2 deletions app/models/githubactivity.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export async function getGitActivityData(projectId: string) {
return await prisma.gitHubActivity.findMany({ where: { projectId }, orderBy: { id: "desc" }});
}

export const getActivityStadistic = async (week: number) => {
return await prisma.$queryRaw<gitHubActivityChartType[]>`SELECT Count(*)::int, "typeEvent" FROM "GitHubActivity" where date_part('week', "created_at")=${week} GROUP BY "typeEvent"`;
export const getActivityStadistic = async (week: number, projectId: string) => {
return await prisma.$queryRaw<gitHubActivityChartType[]>`SELECT Count(*)::int, "typeEvent" FROM "GitHubActivity" where date_part('week', "created_at")=${week} AND "projectId" = ${projectId} GROUP BY "typeEvent"`;

}

2 changes: 1 addition & 1 deletion app/routes/projects/$projectId/github-info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import { useLoaderData, useSubmit } from "@remix-run/react";
throw new Response("Not Found", { status: 404 });
}
const activityData = await getGitActivityData(projectId);
const activityChartData:gitHubActivityChartType[] = await getActivityStadistic(weekParams ? weekParams : week);
const activityChartData:gitHubActivityChartType[] = await getActivityStadistic(weekParams ? weekParams : week, projectId);

return json<LoaderData>({
project,
Expand Down