Skip to content

Geminiの分析情報をDBに入れる (#159)#165

Merged
KOU050223 merged 3 commits intomainfrom
vk/6022-gemini-db-159
Jan 28, 2026
Merged

Geminiの分析情報をDBに入れる (#159)#165
KOU050223 merged 3 commits intomainfrom
vk/6022-gemini-db-159

Conversation

@KOU050223
Copy link
Owner

@KOU050223 KOU050223 commented Jan 25, 2026

GitHub issue #159: Geminiによる分析情報をデータベースに保存する機能を実装

Summary by CodeRabbit

  • New Features

    • Analysis comments can now be saved and retrieved for anime viewing trends.
    • Added persistent "Analyze" button with loading indicator showing analysis progress.
  • Improvements

    • Previously saved analysis comments are now displayed when viewing anime data.
    • Enhanced UI layout and flow for the analysis workflow.

✏️ Tip: You can customize this high-level summary in your review settings.

- ScanDataServiceにsaveAnalysisCommentメソッドを追加
- QRスキャン画面で分析後に自動的にFirestoreへ保存
- 既存の分析結果がある場合は初期表示
- 再分析ボタンで最新の分析結果に更新可能
- users/{userId}/meishies/{friendUserId}コレクションに保存
@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

Warning

Rate limit exceeded

@KOU050223 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The changes introduce analysis comment persistence functionality by adding a new saveAnalysisComment method to the service layer and integrating it with the UI to fetch and store analysis comments in Firebase, alongside UI restructuring for the analysis workflow.

Changes

Cohort / File(s) Summary
Service Layer
lib/ui/camera/services/scan_data_service.dart
New saveAnalysisComment method added to persist analysis comments to Firebase under users/{currentUserId}/meishies/{friendUserId} with fields for analysisComment and updatedAt. Existing methods getAnimeDetails and getAnalysisComment refactored to multiline parameter signatures.
View Integration
lib/ui/camera/view/scandata.dart
Added FirebaseAuth integration to fetch current user ID and load existing analysis comments on data fetch. New UI flow introduces persistent "AIで視聴傾向を分析" button that toggles to "AIで再分析" after analysis, with dedicated loading indicator and conditional comment display. Analysis comments now persisted after computation via saveAnalysisComment.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as Scan View
    participant Service as ScanDataService
    participant Firebase as Firebase<br/>(Firestore + Auth)

    User->>UI: Load scan data
    UI->>Firebase: Get current user ID
    Firebase-->>UI: User ID
    UI->>Service: getAnalysisComment(currentUserId,<br/>friendUserId)
    Service->>Firebase: Query analysis comment
    Firebase-->>Service: Comment data
    Service-->>UI: Existing comment
    UI->>UI: Display comment (if exists)

    User->>UI: Trigger AI analysis
    UI->>UI: Show loading indicator
    UI->>Service: Perform analysis
    Service-->>UI: Analysis comment result
    UI->>Service: saveAnalysisComment(currentUserId,<br/>friendUserId, comment)
    Service->>Firebase: Persist comment & timestamp
    Firebase-->>Service: Success
    Service-->>UI: Saved
    UI->>UI: Update UI with new comment
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • Issue #159: Analysis comment persistence — This PR directly implements the core functionality by adding saveAnalysisComment method and wiring it into the UI to store analysis comments in Firebase.

Poem

🐰 Analysis comments take their flight,
Stored in Firebase's vault so tight,
The service layer hops with grace,
Data persists in its rightful place,
A fluffy hop toward persistence bright! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and lacks the structured sections required by the template (概要, 変更内容, 関連Issue, テスト, スクリーンショット). Expand the description to follow the provided template by adding structured sections including change details, test confirmation checkboxes, and relevant issue references.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'Geminiの分析情報をDBに入れる (#159)' clearly summarizes the main change: persisting Gemini analysis information to the database, which aligns with the primary objectives of adding saveAnalysisComment functionality and storing analysis results in Firestore.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 25, 2026

Visit the preview URL for this PR (updated for commit 83b13eb):

https://animeishi-73560--pr165-vk-6022-gemini-db-15-19ppdxj3.web.app

(expires Wed, 04 Feb 2026 14:56:44 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f1f494a67df8ccbb2232f73b6ccab4934a51e505

@KOU050223 KOU050223 self-assigned this Jan 26, 2026
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.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@lib/ui/camera/services/scan_data_service.dart`:
- Around line 154-174: The success log in saveAnalysisComment currently prints
raw user IDs (currentUserId and friendUserId); remove those identifiers from
logs to avoid exposing PII—update the print('analysisComment保存成功: $currentUserId
-> $friendUserId') to a non-identifying message (e.g., 'analysisComment保存成功') or
log a masked identifier if needed, and ensure no other places in
saveAnalysisComment output raw IDs.

In `@lib/ui/camera/view/scandata.dart`:
- Around line 113-121: The Firestore persistence call to
ScanDataService.saveAnalysisComment is allowed to throw and bubble up, masking a
successful analysis; wrap that call in its own try-catch so persistence errors
are swallowed/logged without altering the outer flow. Locate the block that
checks currentUserId and calls ScanDataService.saveAnalysisComment (the
currentUserId variable and ScanDataService.saveAnalysisComment call) and change
it to call saveAnalysisComment inside a new try { await
ScanDataService.saveAnalysisComment(...) } catch (e, st) { log the error via
your logger or FirebaseCrashlytics but do not rethrow } so the generated comment
is preserved even when saving fails.
- Around line 64-75: The code calls setState() after awaiting async work (e.g.,
after ScanDataService.getAnalysisComment) which can throw "setState() called
after dispose"; add a mounted guard before calling setState — for example, after
the await that retrieves savedComment check if (!mounted) return; then call
setState(() { analysisComment = savedComment; });; apply the same pattern to
other post-await setState() calls in this class (including in _runAnalysis()) to
avoid updating state on disposed widgets.

@KOU050223 KOU050223 changed the title Geminiの分析情報をDBに入れる (#159) (vibe-kanban) Geminiの分析情報をDBに入れる (#159) Jan 28, 2026
- ユーザーIDのログ出力を削除してプライバシーを保護
- 非同期処理後のsetState()にmountedチェックを追加
- saveAnalysisCommentのエラーを分離して分析結果を保護
@KOU050223 KOU050223 merged commit 2d698b7 into main Jan 28, 2026
5 checks passed
@KOU050223 KOU050223 deleted the vk/6022-gemini-db-159 branch January 28, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant