Skip to content
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
32 changes: 32 additions & 0 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,31 @@ paths:
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/team-space/{projectGroupId}/github/users/{targetUserId}/weekly-summaries/{weeklyGithubSummaryId}:
get:
tags: [TeamSpace]
security:
- bearerAuth: []
summary: Get one weekly GitHub activity summary for a team member
parameters:
- $ref: '#/components/parameters/ProjectGroupId'
- $ref: '#/components/parameters/TargetUserId'
- $ref: '#/components/parameters/WeeklyGithubSummaryId'
responses:
'200':
description: Weekly GitHub summary
content:
application/json:
schema:
$ref: '#/components/schemas/GithubWeeklySummary'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
components:
securitySchemes:
bearerAuth:
Expand Down Expand Up @@ -1184,6 +1209,13 @@ components:
schema:
type: integer
format: int64
WeeklyGithubSummaryId:
in: path
name: weeklyGithubSummaryId
required: true
schema:
type: integer
format: int64
schemas:
ApiError:
type: object
Expand Down
51 changes: 51 additions & 0 deletions src/features/team/hooks/use-team-space-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getGithubInstallationStatus,
getGithubRepositories,
getGithubRepositoryContributions,
getGithubWeeklySummary,
getGithubWeeklySummaries,
getTeamRule,
regenerateDevGuide,
Expand All @@ -24,6 +25,7 @@ import type {
DevGuideQueryResponse,
GithubAppInstallationCompleteRequest,
GithubRepositoryContributionRequest,
GithubWeeklySummaryDetailRequest,
RegenerateDevGuideRequest,
SetGithubRepositoriesRequest,
TeamRuleResponse,
Expand Down Expand Up @@ -64,6 +66,20 @@ export const teamSpaceQueryKeys = {
targetUserId,
"weekly-summaries",
] as const,
githubWeeklySummary: (
projectGroupId: number,
targetUserId: number,
weeklyGithubSummaryId: number,
) =>
[
"team-space",
projectGroupId,
"github",
"users",
targetUserId,
"weekly-summaries",
weeklyGithubSummaryId,
] as const,
githubStatus: (projectGroupId: number) =>
["team-space", projectGroupId, "github", "status"] as const,
teamRule: (projectGroupId: number) =>
Expand Down Expand Up @@ -420,3 +436,38 @@ export function useGithubWeeklySummariesQuery(
staleTime: githubContributionStaleTimeMs,
});
}

export function useGithubWeeklySummaryQuery(
projectGroupId: number | undefined,
targetUserId: number | undefined,
weeklyGithubSummaryId: number | undefined,
enabled = true,
) {
const hasIds =
typeof projectGroupId === "number" &&
typeof targetUserId === "number" &&
typeof weeklyGithubSummaryId === "number";

return useQuery({
enabled: enabled && hasIds,
queryFn: () =>
getGithubWeeklySummary({
projectGroupId: requireProjectGroupId(projectGroupId),
targetUserId: requireNumericId(targetUserId, "Target user id"),
weeklyGithubSummaryId: requireNumericId(
weeklyGithubSummaryId,
"Weekly Github summary id",
),
} satisfies GithubWeeklySummaryDetailRequest),
queryKey: hasIds
? teamSpaceQueryKeys.githubWeeklySummary(
projectGroupId,
targetUserId,
weeklyGithubSummaryId,
)
: teamSpaceQueryKeys.disabled,
refetchOnWindowFocus: false,
retry: false,
staleTime: githubContributionStaleTimeMs,
});
}
48 changes: 48 additions & 0 deletions src/lib/api/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3001,4 +3001,52 @@ export const handlers = [
return HttpResponse.json(createMockGithubWeeklySummaries(targetUserId));
},
),

http.get(
getPath(
"/team-space/:projectGroupId/github/users/:targetUserId/weekly-summaries/:weeklyGithubSummaryId",
),
async ({ params, request }) => {
await delay(300);
syncSessionFromRequest(request);

const projectGroupId = Number(params.projectGroupId);
const targetUserId = Number(params.targetUserId);
const weeklyGithubSummaryId = Number(params.weeklyGithubSummaryId);
const accessError = assertProjectGroupAccess(projectGroupId);

if (accessError) {
return accessError;
}

const targetMember = activeProjectGroup?.members.find(
(member) => member.userId === targetUserId,
);

if (!targetMember) {
return buildErrorResponse(
404,
"팀 멤버를 찾을 수 없습니다.",
"PROJECT_GROUP_MEMBER_NOT_FOUND",
);
}

const summary = createMockGithubWeeklySummaries(
targetUserId,
).summaries.find(
(candidate) =>
candidate.weeklyGithubSummaryId === weeklyGithubSummaryId,
);

if (!summary) {
return buildErrorResponse(
404,
"주간 GitHub 요약을 찾을 수 없습니다.",
"WEEKLY_GITHUB_SUMMARY_NOT_FOUND",
);
}

return HttpResponse.json(summary);
},
),
];
7 changes: 7 additions & 0 deletions src/lib/api/team-space.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import {
confirmDevGuide,
getDevGuideHistories,
getDevGuideHistoryContent,
getGithubWeeklySummary,
getGithubWeeklySummaries,
} from "@/lib/api/team-space";
import type {
ConfirmDevGuideRequest,
DevGuideHistoryContentResponse,
DevGuideHistoryListResponse,
GithubWeeklySummary,
GithubWeeklySummaryDetailRequest,
GithubWeeklySummaryListResponse,
GithubWeeklySummaryRequest,
} from "@/lib/types/team-space";
Expand All @@ -23,11 +26,15 @@ type TeamSpaceServerOnlyApiContract = {
getGithubWeeklySummaries: (
payload: GithubWeeklySummaryRequest,
) => Promise<GithubWeeklySummaryListResponse>;
getGithubWeeklySummary: (
payload: GithubWeeklySummaryDetailRequest,
) => Promise<GithubWeeklySummary>;
};

export const teamSpaceServerOnlyApiContract = {
confirmDevGuide,
getDevGuideHistories,
getDevGuideHistoryContent,
getGithubWeeklySummary,
getGithubWeeklySummaries,
} satisfies TeamSpaceServerOnlyApiContract;
12 changes: 12 additions & 0 deletions src/lib/api/team-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type {
GithubRepositoryContributionRequest,
GithubRepositoryContributionResponse,
GithubRepositoryListResponse,
GithubWeeklySummary,
GithubWeeklySummaryDetailRequest,
GithubWeeklySummaryListResponse,
GithubWeeklySummaryRequest,
RegenerateDevGuideRequest,
Expand Down Expand Up @@ -177,3 +179,13 @@ export function getGithubWeeklySummaries({
`/team-space/${projectGroupId}/github/users/${targetUserId}/weekly-summaries`,
);
}

export function getGithubWeeklySummary({
projectGroupId,
targetUserId,
weeklyGithubSummaryId,
}: GithubWeeklySummaryDetailRequest) {
return apiRequest<GithubWeeklySummary>(
`/team-space/${projectGroupId}/github/users/${targetUserId}/weekly-summaries/${weeklyGithubSummaryId}`,
);
}
5 changes: 5 additions & 0 deletions src/lib/types/team-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ export interface GithubWeeklySummaryRequest {
targetUserId: number;
}

export interface GithubWeeklySummaryDetailRequest
extends GithubWeeklySummaryRequest {
weeklyGithubSummaryId: number;
}

export interface GithubWeeklySummaryContent {
followUpSuggestions: string[];
issueHighlights: string[];
Expand Down
Loading