Skip to content

Commit

Permalink
Merge pull request #243 from wizeline/fix/242/githubActivity-should-r…
Browse files Browse the repository at this point in the history
…eturn-data-by-id

fix/242/github stadistics should return data by project id
  • Loading branch information
martinrobled0 authored Oct 12, 2023
2 parents 4ecc0a1 + 9da60a1 commit 48227f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit 48227f8

Please sign in to comment.