Skip to content
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

[refactor] projectのマイグレーションを関数切り出し #1967

Conversation

Hiroshiba
Copy link
Member

内容

プロジェクトファイルのマイグレーションをファイル切り出ししてテスト可能にしたいです。
第2弾として、projectのマイグレーションを関数切り出しました。

の続きタスクです。

関連 Issue

その他

#1965 がマージされた後に

git --no-pager  diff -w --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space upstream/main

したら変更は移動だけなことがわかるかと!

@Hiroshiba Hiroshiba marked this pull request as ready for review May 4, 2024 15:02
@Hiroshiba Hiroshiba requested a review from a team as a code owner May 4, 2024 15:02
Copy link
Member Author

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

ほぼ移動だけなのですが、関数化する方法とかで2箇所考慮事項が入ってます

Comment on lines +19 to +28
/**
* プロジェクトファイルのフォーマットエラー
* FIXME: Result型にする
*/
export class ProjectFileFormatError extends Error {
constructor(message: string) {
super(message);
this.name = "ProjectFileFormatError";
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

エラーメッセージでエラー判断してたところを、ちゃんとエラークラスを定義するようにしました。
本当はResult型にした方が良さそうだけど、このエラーを受ける側も全部変えないといけないので、簡易的にエラークラスを作ることにしました。

Comment on lines +77 to +88
export const migrateProjectFileObject = async (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
projectData: any,
DI: {
fetchMoraData: (payload: {
accentPhrases: AccentPhrase[];
engineId: EngineId;
styleId: StyleId;
}) => Promise<AccentPhrase[]>;
characterInfos: CharacterInfo[];
},
) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

エンジンを叩く関数と、エンジンから帰ってきたキャラクター情報が必要だったのでDIの形として渡すようにしました。

Copy link
Member

@Segu-g Segu-g left a comment

Choose a reason for hiding this comment

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

LGTM!

@Hiroshiba
Copy link
Member Author

Hiroshiba commented May 20, 2024

@Segu-g レビューありがとうございます!!!

マージします!!

追記:ちょっとちゃんとしたコンフリクト改修が必要でした 🙇

@Hiroshiba
Copy link
Member Author

コンフリクト解消したのでマージします!

@Hiroshiba Hiroshiba merged commit ef3477d into VOICEVOX:main May 21, 2024
9 checks passed
@Hiroshiba Hiroshiba deleted the projectのマイグレーションを関数切り出し branch May 21, 2024 17:26
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.

None yet

2 participants