データセット作成
説明
データセット作成機能は、高度な商品分析とビジネスインテリジェンス生成のためのTV Python APIとの高度な統合を提供します。このシステムは、ウィッシュリストデータを機械学習分析用の包括的なデータセットに変換し、商品パフォーマンス、市場トレンド、競合ポジショニングに関する深いインサイトを可能にします。
この機能は、ウィッシュリスト管理と高度な分析の橋渡しとして機能し、以下を提供します:
- ウィッシュリストデータからの自動データセット準備
- 高度な分析のためのTV Python API統合
- リアルタイムステータス監視と進捗追跡
- 包括的なエラーハンドリングと再試行メカニズム
- 履歴データセット追跡と管理
- トレーニングステータス管理とスケジューリング
システムは、トランザクション安全な操作によりデータ整合性を確保し、最適なユーザーエクスペリエンスのためのPusher統合によるリアルタイム更新を提供します。
アクティビティ図
---
config:
theme: base
layout: dagre
flowchart:
curve: linear
htmlLabels: true
themeVariables:
edgeLabelBackground: "transparent"
---
flowchart TB
%% Main components
UserRequest[ユーザーリクエスト]
Database[(Database)]
subgraph Controllers
WishlistController[WishlistToGroupController]
end
subgraph Services
AnalysisService(ProductAnalysisService)
DatasetService(WishlistDatasetHistoryService)
end
subgraph ExternalAPIs
TVPythonAPI((TV Python API))
PusherService((Pusher Service))
end
subgraph Middleware
AuthMiddleware{AuthMiddleware}
end
UserRequest --- Step1[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>1</span>
<p style='margin-top: 8px'>認証・ウィッシュリスト検証</p>
</div>
]
Step1 --> AuthMiddleware
AuthMiddleware --> WishlistController
WishlistController --- Step2[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>2</span>
<p style='margin-top: 8px'>データセット準備・検証</p>
</div>
]
Step2 --> AnalysisService
AnalysisService --> Database
AnalysisService --- Step3[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>3</span>
<p style='margin-top: 8px'>TV Python API統合</p>
</div>
]
Step3 --> TVPythonAPI
TVPythonAPI --- Step4[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>4</span>
<p style='margin-top: 8px'>データセット履歴・ステータス追跡</p>
</div>
]
Step4 --> DatasetService
DatasetService --> Database
DatasetService --- Step5[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>5</span>
<p style='margin-top: 8px'>リアルタイム監視・更新</p>
</div>
]
Step5 --> PusherService
TVPythonAPI -.-> DatasetService
PusherService --- Step6[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>6</span>
<p style='margin-top: 8px'>結果処理・トレーニングステータス</p>
</div>
]
Step6 --> WishlistController
%% Styling
style UserRequest fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
style Database fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
style TVPythonAPI fill:#fcd9d9,stroke:#cc3333,stroke-width:2px
style PusherService fill:#fcd9d9,stroke:#cc3333,stroke-width:2px
style Controllers fill:#e6f3ff
style Services fill:#f0f8e6
style ExternalAPIs fill:#fcd9d9
style Middleware fill:#f5f0ff
style Step1 fill:transparent,stroke:transparent,stroke-width:1px
style Step2 fill:transparent,stroke:transparent,stroke-width:1px
style Step3 fill:transparent,stroke:transparent,stroke-width:1px
style Step4 fill:transparent,stroke:transparent,stroke-width:1px
style Step5 fill:transparent,stroke:transparent,stroke-width:1px
style Step6 fill:transparent,stroke:transparent,stroke-width:1px
詳細データフロー依存関係
ステップバイステッププロセス
ステップ1: 認証・ウィッシュリスト検証
- 説明: データセット作成のためのユーザー認証、ウィッシュリストアクセス、サブスクリプションステータスを検証
- アクション: ユーザー認証、ウィッシュリスト所有権検証、サブスクリプション有効性チェック、グループメンバーシップ確認
- 入力: ユーザー認証情報、ウィッシュリストスラッグ、サブスクリプション詳細、グループメンバーシップデータ
- 出力: ウィッシュリストアクセスとサブスクリプション確認付きの検証されたユーザーコンテキスト
- 依存関係: ユーザー認証サービス、ウィッシュリストリポジトリ、サブスクリプション検証
- 外部サービス: 認証プロバイダー、サブスクリプション課金システム
ステップ2: データセット準備・検証
- 説明: TV Python API統合のためのウィッシュリストデータを準備し、データセット要件を検証
- アクション: ウィッシュリスト商品/カテゴリ/クエリ集約、データ完全性検証、既存データセットチェック
- 入力: ウィッシュリストデータ、商品詳細、カテゴリ情報、検索クエリ
- 出力: 検証結果と競合チェック付きのフォーマットされたデータセットリクエスト
- 依存関係: ウィッシュリストデータサービス、データセット履歴サービス、データ検証
- 外部サービス: 商品検証API、データ整合性サービス
ステップ3: TV Python API統合
- 説明: 適切なフォーマットとエラーハンドリングでTV Python APIにデータセット作成リクエストを送信
- アクション: TV Python API用データフォーマット、HTTPリクエスト送信、APIレスポンス処理、タイムアウト管理
- 入力: フォーマットされたデータセットリクエスト、API認証情報、設定パラメータ
- 出力: 追跡IDと初期ステータス付きのデータセット作成レスポンス
- 依存関係: TV Python APIクライアント、HTTPサービス、設定管理
- 外部サービス: TV Python API、データセットストレージサービス、APIゲートウェイ
ステップ4: データセット履歴・ステータス追跡
- 説明: データセット履歴レコードを作成し、リアルタイムステータス監視を初期化
- アクション: 履歴レコード作成、ステータス追跡初期化、監視設定、通知設定
- 入力: データセットレスポンス、追跡ID、ウィッシュリストコンテキスト、ユーザー設定
- 出力: 監視設定と通知設定付きのデータセット履歴レコード
- 依存関係: データセット履歴サービス、ステータス追跡サービス、通知サービス
- 外部サービス: データベースクラスター、監視システム、通知キュー
ステップ5: リアルタイム監視・進捗更新
- 説明: リアルタイム更新とステータス通知でデータセット分析進捗を監視
- アクション: TV Python APIステータスポーリング、進捗更新、Pusher通知送信、ステータス変更処理
- 入力: データセット追跡ID、ポーリング設定、通知設定
- 出力: リアルタイムステータス更新、進捗通知、完了アラート
- 依存関係: ポーリングサービス、通知サービス、ステータス管理
- 外部サービス: TV Python APIステータスエンドポイント、Pusherリアルタイムサービス、監視ダッシュボード
ステップ6: 結果処理・トレーニングステータス管理
- 説明: 分析完了を処理し、トレーニングステータスを更新し、結果可用性を管理
- アクション: 完了ステータス処理、トレーニング設定更新、結果アクセス管理、エラー処理
- 入力: 分析完了データ、トレーニング設定、エラー情報
- 出力: 更新されたトレーニングステータス、結果可用性、エラーハンドリング
- 依存関係: トレーニングステータスサービス、結果処理、エラー管理
- 外部サービス: 結果ストレージサービス、トレーニングスケジューラー、エラー報告システム
データベース関連テーブル・フィールド
データベース: gb_console
erDiagram
wishlist_dataset_histories {
bigint id PK
bigint wishlist_to_group_id FK
bigint dataset_id
string slug
integer status "データセットのステータス"
}
wishlist_to_groups {
bigint id PK
string name "ウィッシュリストの名前"
string slug "ウィッシュリストのスラッグ"
integer status "0: 非アクティブ, 1: アクティブ, 3: キャンセル"
}
wishlist_dataset_histories }|--|| wishlist_to_groups : "所属"
ケースドキュメント
ケース1: 分析用データセット作成
API: データセット作成
シーケンス図
sequenceDiagram
participant Client
participant Controller as WishlistToGroupController
participant Service as ProductAnalysisService
participant Repository as WishlistToGroupRepository
participant HistoryRepo as WishlistDatasetHistoryRepository
participant TVPythonAPI as TV Python API
participant Pusher as Pusher Service
participant Database
Note over Client,Database: 分析用データセット作成フロー
rect rgb(255, 255, 200)
Note right of Client: 認証フェーズ
Client->>Controller: POST /api/v1/wishlist-to-group/{slug}/createAnalysis
Controller->>Controller: ユーザー認証
Controller->>Repository: findBySlug(slug)
Repository->>Database: ウィッシュリストSELECT
Database-->>Repository: ウィッシュリストレコード
Repository-->>Controller: ウィッシュリストまたはnull
end
rect rgb(200, 230, 255)
Note right of Controller: 検証フェーズ
Controller->>Controller: グループアクセス検証
Controller->>Controller: サブスクリプションステータスチェック
Controller->>Controller: データセット履歴検証
alt 検証失敗
Controller-->>Client: エラーレスポンス
end
end
rect rgb(200, 255, 255)
Note right of Controller: データセット準備
Controller->>Service: createDatasetForWishlistToGroup(wishlist)
Service->>Service: データセットリクエスト準備
Service->>Service: ウィッシュリストデータ集約
Service->>Service: TV Python API用フォーマット
end
rect rgb(255, 230, 200)
Note right of Service: TV Python API統合
Service->>TVPythonAPI: POST /dataset/create
TVPythonAPI->>TVPythonAPI: データセットリクエスト処理
TVPythonAPI-->>Service: データセット作成レスポンス
Service->>Service: データセットID抽出
end
rect rgb(230, 200, 255)
Note right of Service: 履歴・ステータス追跡
Service->>HistoryRepo: create(datasetHistory)
HistoryRepo->>Database: dataset_history INSERT
Database-->>HistoryRepo: 作成されたレコード
Service->>Service: ステータス監視初期化
end
rect rgb(200, 255, 200)
Note right of Service: 成功レスポンス
Service-->>Controller: 成功結果
Controller->>Pusher: 初期通知送信
Pusher->>Client: リアルタイムステータス更新
Controller-->>Client: データセットID付きJSONレスポンス
end
rect rgb(255, 200, 200)
Note right of Service: エラーハンドリング
alt TV Python APIエラー
TVPythonAPI-->>Service: APIエラーレスポンス
Service->>Service: エラー詳細ログ
Service-->>Controller: APIエラー
else データベースエラー
Database-->>HistoryRepo: データベースエラー
HistoryRepo-->>Service: 作成失敗
Service-->>Controller: データベースエラー
else サブスクリプションエラー
Controller->>Controller: サブスクリプション無効
Controller-->>Client: サブスクリプションエラー
end
Controller-->>Client: エラーレスポンス
end
ステップ
- 認証・認可: ユーザーとウィッシュリストアクセスを検証
- サブスクリプション検証: サブスクリプションステータスと有効性をチェック
- データセット履歴チェック: アクティブなデータセット処理がないことを確認
- データ準備: TV Python API用にウィッシュリストデータを集約・フォーマット
- API統合: TV Python APIにデータセット作成リクエストを送信
- 履歴作成: 追跡ID付きのデータセット履歴レコードを作成
- ステータス監視: リアルタイムステータス監視を初期化
- 通知設定: 進捗更新用のPusher通知を設定
エラーハンドリング
- 401 Unauthorized: 無効な認証
- 404 Not Found: ウィッシュリストが見つからないまたはアクセス拒否
- 402 Payment Required: サブスクリプション期限切れまたは無効
- 409 Conflict: データセットが既に処理中
- 503 Service Unavailable: TV Python API利用不可
- 500 Internal Server Error: データベースまたはシステムエラー
ケース2: データセット履歴取得
API: データセット履歴取得
シーケンス図
sequenceDiagram
participant Client
participant Controller as WishlistToGroupController
participant Service as WishlistDatasetHistoryService
participant Repository as WishlistDatasetHistoryRepository
participant Database
Note over Client,Database: データセット履歴取得フロー
rect rgb(255, 255, 200)
Note right of Client: 認証フェーズ
Client->>Controller: GET /api/v1/wishlist-to-group/{slug}/histories
Controller->>Controller: ユーザー認証
Controller->>Controller: ウィッシュリストアクセス検証
end
rect rgb(200, 230, 255)
Note right of Controller: 検証フェーズ
Controller->>Controller: クエリパラメータ検証
Controller->>Service: getWishlistHistoriesById(params, wishlist)
Service->>Service: フィルタとソート適用
end
rect rgb(230, 200, 255)
Note right of Service: データベースクエリ
Service->>Repository: findWhere(conditions)
Repository->>Database: ページネーション付きSELECT
Database-->>Repository: 履歴レコード
Repository-->>Service: ページネーションコレクション
end
rect rgb(200, 255, 200)
Note right of Service: 成功レスポンス
Service-->>Controller: ページネーション履歴
Controller->>Controller: リソースに変換
Controller-->>Client: ページネーション付きJSONレスポンス
end
ステップ
- 認証: ユーザーセッションとウィッシュリストアクセスを検証
- パラメータ検証: ページネーションとフィルタパラメータを検証
- クエリ実行: 適切なフィルタリングでページネーションクエリを実行
- データ変換: 結果をAPIリソース形式に変換
- レスポンス生成: メタデータ付きのページネーション結果を返却
エラーハンドリング
- 401 Unauthorized: 無効な認証
- 404 Not Found: ウィッシュリストが見つからないまたはアクセス拒否
- 400 Bad Request: 無効なクエリパラメータ
- 500 Internal Server Error: データベースまたはシステムエラー
ケース3: トレーニングステータス更新
API: トレーニングステータス更新
シーケンス図
sequenceDiagram
participant Client
participant Controller as WishlistToGroupController
participant Service as WishlistToGroupService
participant Repository as WishlistToGroupRepository
participant Database
Note over Client,Database: トレーニングステータス更新フロー
rect rgb(255, 255, 200)
Note right of Client: 認証フェーズ
Client->>Controller: PATCH /api/v1/wishlist-to-group/{slug}/update-tranning-status
Controller->>Controller: ユーザー認証
Controller->>Controller: ウィッシュリストアクセス検証
end
rect rgb(200, 230, 255)
Note right of Controller: 検証フェーズ
Controller->>Controller: リクエストデータ検証
Controller->>Controller: データセットステータスチェック
Controller->>Controller: トレーニング権限検証
end
rect rgb(200, 255, 255)
Note right of Controller: ステータス更新
Controller->>Service: changeTranningStatus(data, wishlist)
Service->>Service: ステータス遷移検証
Service->>Repository: update(wishlist, data)
Repository->>Database: training_status UPDATE
Database-->>Repository: 更新結果
end
rect rgb(200, 255, 200)
Note right of Repository: 成功レスポンス
Repository-->>Service: 更新成功
Service-->>Controller: 成功結果
Controller-->>Client: 成功レスポンス
end
ステップ
- 認証・認可: ユーザーとウィッシュリストアクセスを検証
- リクエスト検証: トレーニングステータス更新データを検証
- データセットステータスチェック: データセットがトレーニング更新準備完了であることを確認
- ステータス遷移: ステータス遷移を検証・実行
- データベース更新: データベースのトレーニングステータスを更新
- レスポンス生成: 成功確認を返却
エラーハンドリング
- 401 Unauthorized: 無効な認証
- 404 Not Found: ウィッシュリストが見つからないまたはアクセス拒否
- 400 Bad Request: 無効なステータス遷移またはデータ
- 409 Conflict: データセットがトレーニング更新準備未完了
- 500 Internal Server Error: データベースまたはシステムエラー