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

feat: flavor 毎に内部データベース名を変更 #291

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

tatsutakein
Copy link
Member

@tatsutakein tatsutakein commented Mar 11, 2024

Issue

  • close #ISSUE_NUMBER 🦕

概要

flavor 毎に内部データベース名を変更します.

レビュー観点

レビューレベル

  • Lv0: まったく見ないで Approve する
  • Lv1: ぱっとみて違和感がないかチェックして Approve する
  • Lv2: 仕様レベルまで理解して、仕様通りに動くかある程度検証して Approve する
  • Lv3: 実際に環境で動作確認したうえで Approve する

レビュー優先度

  • すぐに見てもらいたい ( hotfix など ) 🚀
  • 今日中に見てもらいたい 🚗
  • 今日〜明日中で見てもらいたい 🚶
  • 数日以内で見てもらいたい 🐢

参考リンク

スクリーンショット

Before After

Summary by CodeRabbit

  • 新機能

    • アプリケーションとアクティビティのコンテキストに名前付きインスタンスを提供するための設定を追加しました。
    • 開発環境と本番環境のデータベース名を切り替えるロジックを更新しました。
  • バグ修正

    • ビルド設定に基づいてデータベース名を動的に生成する機能を改善しました。
  • リファクタ

    • データベースのドライバー作成にBuildConfigを使用するように変更しました。

Copy link

coderabbitai bot commented Mar 11, 2024

概要

この変更の概要は、KotlinのAndroidおよびiOSのプロジェクトにおいて、依存性注入フレームワークであるKoinを使用して、開発環境と本番環境のデータベース名を動的に切り替えるロジックを導入したことです。具体的には、BuildConfigを用いてアプリのフレーバー(開発版か本番版か)を判断し、それに基づいてデータベースの名前を変更する機能が追加されました。

変更点

ファイルのパス 変更の概要
app/.../MainActivity.kt org.koin.core.qualifier.namedのインポートを追加し、"application" と "activity" のための名前付きContextインスタンスを提供するようにKoinモジュール設定を変更
core/.../Database.android.kt & core/.../Database.ios.kt DriverFactoryクラスにBuildConfigパラメータを追加し、databaseName関数を使用してnameプロパティを更新
core/.../DatabaseModule.android.kt & core/.../DatabaseModule.ios.kt createDriverFactory関数にbuildConfigパラメータを追加してスコープから取得
core/.../Database.kt 開発と本番のデータベース名を切り替えるロジックを更新

🐰🌟
新しい変更、風を切って
データの世界が、また動き出す
ビルドのフレーバー、軽やかに舞う
コードのうさぎ、跳ねる喜びを
この変革に、歌を捧ぐ
🌱🎉

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 95d9d45 and cf08d46.
Files selected for processing (6)
  • app/android/src/androidMain/kotlin/club/nito/app/MainActivity.kt (2 hunks)
  • core/database/src/androidMain/kotlin/club/nito/core/database/Database.android.kt (1 hunks)
  • core/database/src/androidMain/kotlin/club/nito/core/database/di/DatabaseModule.android.kt (1 hunks)
  • core/database/src/commonMain/kotlin/club/nito/core/database/Database.kt (1 hunks)
  • core/database/src/iosMain/kotlin/club/nito/core/database/Database.ios.kt (1 hunks)
  • core/database/src/iosMain/kotlin/club/nito/core/database/di/DatabaseModule.ios.kt (1 hunks)
Additional comments: 10
core/database/src/iosMain/kotlin/club/nito/core/database/di/DatabaseModule.ios.kt (1)
  • 6-8: DriverFactoryのインスタンス作成にbuildConfigパラメータを渡す変更は、アプリケーションのフレーバーに基づいてデータベース名を動的に選択するための良いアプローチです。Koinのget()メソッドを使用してbuildConfigを取得することは、依存性注入のベストプラクティスに従っています。
core/database/src/androidMain/kotlin/club/nito/core/database/di/DatabaseModule.android.kt (2)
  • 4-4: org.koin.core.qualifier.namedのインポートは、Koinの名前付きインスタンスを使用するために適切です。この変更は、依存性注入の設定において重要な役割を果たします。
  • 8-9: DriverFactoryのインスタンス作成にcontextbuildConfigパラメータを渡す変更は、Androidプラットフォームにおいてアプリケーションのフレーバーに基づいてデータベース名を動的に選択するための良いアプローチです。依存性注入のベストプラクティスに従っています。
core/database/src/iosMain/kotlin/club/nito/core/database/Database.ios.kt (2)
  • 7-9: DriverFactoryクラスのコンストラクタにBuildConfigパラメータを追加する変更は、iOSプラットフォームにおいてアプリケーションのフレーバーに基づいてデータベース名を動的に選択するための良いアプローチです。
  • 12-12: createDriver関数内でdatabaseName関数を使用してnameプロパティを設定する変更は、フレーバーに基づいてデータベース名を動的に選択するための適切な方法です。
core/database/src/androidMain/kotlin/club/nito/core/database/Database.android.kt (2)
  • 9-12: DriverFactoryクラスのコンストラクタにbuildConfigパラメータを追加する変更は、Androidプラットフォームにおいてアプリケーションのフレーバーに基づいてデータベース名を動的に選択するための良いアプローチです。
  • 19-19: createDriver関数内でdatabaseName関数を使用してnameプロパティを設定する変更は、フレーバーに基づいてデータベース名を動的に選択するための適切な方法です。
core/database/src/commonMain/kotlin/club/nito/core/database/Database.kt (1)
  • 12-15: Flavor列挙型を使用してデータベース名を動的に生成するロジックの導入は、開発と本番環境のデータを効果的に分離し、アプリケーションのフレーバーに応じて適切なデータベースを選択するための適切な方法です。
app/android/src/androidMain/kotlin/club/nito/app/MainActivity.kt (2)
  • 16-16: org.koin.core.qualifier.namedのインポートは、Koinの名前付きインスタンスを使用するために適切です。この変更は、依存性注入の設定において重要な役割を果たします。
  • 45-52: "application"と"activity"の名前付きインスタンスのContextを提供するKoinモジュール設定の変更は、アプリケーションとアクティビティのコンテキストを依存性注入を通じて利用するための適切な方法です。これにより、アプリケーションの構成と管理が柔軟になります。

@tatsutakein tatsutakein merged commit 8aff709 into main Mar 11, 2024
8 checks passed
@tatsutakein tatsutakein deleted the rt/add-database-flavor branch March 11, 2024 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant