Skip to content

参加登録済みページのバグ修正#3

Merged
yuito-it merged 1 commit intomainfrom
fix/registered-page
Feb 14, 2026
Merged

参加登録済みページのバグ修正#3
yuito-it merged 1 commit intomainfrom
fix/registered-page

Conversation

@Aqua-218
Copy link
Contributor

Issue

#2


変更内容

event.tsにEvent.findByAtendeeUserId()を追加し、EventAttendee経由で「指定ユーザーが参加登録しているイベントのみ」を取得するクエリを実装。
AtendedEventList.tsxでauth.api.getSession()を使ってユーザーIDを取得し、Event.findByAtendeeUserId(userId)に切り替え。未ログイン時は空配列を返すように変更。

Copilot AI review requested due to automatic review settings February 10, 2026 15:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

参加登録済みイベント一覧で「参加していないイベントまで表示される」不具合(Issue #2)を修正し、ログイン中ユーザーが参加登録しているイベントのみ取得するように変更するPRです。

Changes:

  • Event.findByAtendeeUserId() を追加し、EventAttendee 経由で指定ユーザーの参加イベントのみ取得するクエリを実装
  • 参加登録済みイベント一覧コンポーネントを Event.findAll() から Event.findByAtendeeUserId(userId) に切り替え
  • 未ログイン時は空配列を返し、一覧に何も表示しない挙動に変更

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/lib/event.ts 参加者(EventAttendee / participants)で絞り込んだイベント取得APIを追加
src/components/AtendedEventList.tsx セッションからユーザーIDを取得し、参加登録済みイベントのみ表示するように変更

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +220 to +248
const events = await prisma.event.findMany({
where: {
...(status ? { status: { in: status } } : {}),
participants: {
some: {
userId,
status: { in: atendeeStatuses },
},
},
},
});

return events.map(
(event) =>
new Event({
id: event.id,
title: event.title,
description: event.description || undefined,
date: event.date,
startAt: event.startTime || undefined,
endAt: event.endTime || undefined,
registrationDeadline: event.registrationDeadline || undefined,
capacity: event.capacity || undefined,
location: event.location || undefined,
status: event.status as EventStatus,
createdAt: event.createdAt || undefined,
updatedAt: event.updatedAt || undefined,
}),
);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findByAtendeeUserId duplicates the same Prisma->Event mapping logic already used in create / findById / findAll. Adding another copy increases the chance of future drift when fields are added/renamed. Consider extracting a shared converter (e.g., a private fromDb(event) helper) and reusing it here and in the existing find methods.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +12
const session = await auth.api.getSession({
headers: await headers(),
});
const userId = session?.user?.id;
const events = userId ? await Event.findByAtendeeUserId(userId) : [];
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AttendedEventList fetches the session itself. On pages that already call auth.api.getSession() (e.g. src/app/events/attended/page.tsx), this results in duplicate session lookups per request. Consider passing userId (or the session) into this component when available and only calling getSession as a fallback when the prop isn’t provided.

Copilot uses AI. Check for mistakes.
@yuito-it yuito-it force-pushed the fix/registered-page branch from 3fb96fa to e4d6201 Compare February 14, 2026 23:28
@yuito-it yuito-it merged commit 2ef49b9 into main Feb 14, 2026
2 checks passed
@yuito-it yuito-it deleted the fix/registered-page branch February 14, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants