Skip to content

ユーザー情報に基づいたソートを実装#12

Open
KurenNagata wants to merge 11 commits into
mainfrom
featur/academic-sort
Open

ユーザー情報に基づいたソートを実装#12
KurenNagata wants to merge 11 commits into
mainfrom
featur/academic-sort

Conversation

@KurenNagata

Copy link
Copy Markdown

やったこと

  • 専門が先に来るように変更
  • 一致したコースが先に来るように変更
  • 一致した学年が先に来るように変更

確認したこと

  • curl コマンドで正しく帰ってくることを確認

@KurenNagata KurenNagata requested review from hikaru-0602, kantacky, masaya-osuga, sayo-o518 and zakiPoteto and removed request for sayo-o518 June 5, 2026 04:17
@kantacky kantacky requested a review from a team June 5, 2026 04:19
@masaya-osuga masaya-osuga requested a review from Copilot June 5, 2026 04:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

科目一覧 API に userId クエリを追加し、指定ユーザーの「コース・学年」に基づいて科目の並び順を最適化する変更です。併せて、OpenAPI / 生成コード(oapi-codegen)を更新しています。

Changes:

  • userId 指定時にユーザー属性(専門区分 → コース → 学年)に基づく安定ソートを適用
  • Academic モジュールに User の domain / repository を追加してユーザー属性を取得
  • OpenAPI と gen/academic を更新し、userId パラメータを API に反映

Reviewed changes

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

Show a summary per file
File Description
internal/modules/academic/service/subject.go SortByUserAttribute フラグに応じて科目リストを安定ソート
internal/modules/academic/repository/user.go users テーブルからコース/学年を取得する repo を追加
internal/modules/academic/handler/subject_list.go userId 指定時にユーザー情報を取得してフィルタへ注入
internal/modules/academic/handler/handler.go Handler に userRepo を注入できるように拡張
internal/modules/academic/domain/user.go Academic ドメインに User を追加
internal/modules/academic/domain/subject.go SubjectListFilter にユーザー属性ソート用フィールドを追加
gen/academic/api.gen.go oapi-codegen 再生成(userId パラメータ反映・strict handler 実装更新等)
cmd/academic-api/main.go UserRepository を組み立てて Handler に注入
api/openapi/academic/openapi.yaml /v1/subjectsuserId クエリを追加
Files not reviewed (1)
  • gen/academic/api.gen.go: Language not supported

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

Comment thread cmd/academic-api/main.go
Comment on lines 103 to 105
strictHandler := api.NewStrictHandler(h, []api.StrictMiddlewareFunc{
middleware.DeadlineErrorMapper(),
})
- name: userId
in: query
required: false
description: ユーザーID; 指定した場合はユーザーのコース・学年に近い順にソートする
items:
$ref: '#/components/schemas/DottoFoundationV1.CulturalSubjectCategory'
explode: false
- name: userId

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

openapi.yamlファイルは直接いじるんじゃなくて、TypeSpecリポジトリで管理するんだよね〜
なので、このPRではこの編集はいらないかな

@@ -0,0 +1,7 @@
package domain

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kantacky
user-apiをserverに移行してからの方が良さそうじゃない?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

たしかに〜

}

type userRepository interface {
FindByID(ctx context.Context, id string) (domain.User, bool, error)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

アーキテクチャ的にHandler -> Repositoryの直接依存はしてないはず
既存のAPIエンドポイントがどのようなフローかを見るといいかも👊

Comment thread cmd/academic-api/main.go

// Handler + Router
h := handler.NewHandler(subjectSvc, facultySvc, roomSvc, timetableItemSvc, courseRegistrationSvc, personalCalendarItemSvc, cancelledClassSvc, makeupClassSvc, roomChangeSvc, facultyRoomSvc)
h := handler.NewHandler(subjectSvc, facultySvc, roomSvc, timetableItemSvc, courseRegistrationSvc, personalCalendarItemSvc, cancelledClassSvc, makeupClassSvc, roomChangeSvc, facultyRoomSvc, userRepo)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://github.com/fun-dotto/server/pull/12/changes#r3360449248
に関連して、他のやつは全部Serviceを注入しているはず

return userToDomain(record), true, nil
}

func userToDomain(m model.User) domain.User {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

このファイルの差分自体が多分いらなくなるかもなんだけど、変換処理をこの場所でやっているところは他にない気がする!

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.

4 participants