ランキング分析
説明
ランキング分析機能は、公式ウィッシュリストコンテキスト内でのカテゴリと検索クエリの包括的なランキング分析機能を提供し、ユーザーが商品ランキングとパフォーマンスメトリクスに関するインサイトを得られるようにします。このシステムはアナライザーデータベースと統合して、適切なサブスクリプションベースフィルタリング付きのカテゴリと検索クエリ分析用ランキングデータを提供します。
この機能は以下を備えた本番対応のランキング分析に焦点を当てています:
- サブスクリプションベース日付フィルタリング付きカテゴリランキング分析
- パフォーマンスメトリクス付き検索クエリランキング分析
- ランキングデータのためのアナライザーデータベースとの統合
- サブスクリプションベースデータアクセス制御とフィルタリング
- リアルタイムランキングデータ取得と処理
- 適切なフィルタリング付きページネーションランキング結果
システムはサブスクリプション検証を通じてデータ精度を確保し、市場分析と戦略計画のための包括的なランキング情報を提供します。
アクティビティ図
---
config:
theme: base
layout: dagre
flowchart:
curve: linear
htmlLabels: true
themeVariables:
edgeLabelBackground: "transparent"
---
flowchart TB
%% Main components
UserRequest[ユーザーリクエスト]
Database[(Database)]
subgraph Controllers
CategoryRankingController[ProductCategoryRankingController]
SearchRankingController[ProductSearchQueryRankingController]
end
subgraph Services
CategoryRankingService(ProductCategoryRankingService)
SearchRankingService(ProductSearchQueryRankingService)
end
subgraph Repositories
CategoryRankingRepo[[ProductCategoryRankingRepository]]
SearchRankingRepo[[ProductSearchQueryRankingRepository]]
WishlistRepo[[WishlistToGroupRepository]]
SummaryRepo[[SummaryWishlistCategoryRepository]]
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 --> CategoryRankingController
AuthMiddleware --> SearchRankingController
CategoryRankingController --- 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 --> CategoryRankingService
Step2 --> SearchRankingService
CategoryRankingService --> WishlistRepo
CategoryRankingService --> SummaryRepo
CategoryRankingService --- 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'>サブスクリプションフィルタリング・データ処理</p>
</div>
]
Step3 --> CategoryRankingRepo
Step3 --> SearchRankingRepo
CategoryRankingRepo --> Database
SearchRankingRepo --> Database
CategoryRankingRepo --- 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 --> CategoryRankingController
Step4 --> SearchRankingController
%% Styling
style UserRequest fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
style Database fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
style Controllers fill:#e6f3ff
style Services fill:#f0f8e6
style Repositories fill:#fff0f5
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
詳細データフロー依存関係
ステップバイステッププロセス
ステップ1: 認証・ウィッシュリスト検証
- 説明: ランキング分析操作のためのユーザー認証とウィッシュリストアクセスを検証
- アクション: ユーザーセッション認証、ウィッシュリスト所有権検証、ウィッシュリスト存在チェック
- 入力: ユーザー認証情報、ウィッシュリストスラッグ
- 出力: ウィッシュリストアクセス確認付きの検証されたユーザーコンテキスト
- 依存関係: ユーザー認証サービス、ウィッシュリストリポジトリ
- 外部サービス: 認証プロバイダー
ステップ2: ランキングデータ取得・処理
- 説明: ウィッシュリスト情報を取得し、サブスクリプションコンテキストでランキングパラメータを処理
- アクション: サブスクリプション付きウィッシュリスト読み込み、カテゴリパラメータ検証、ランキングクエリ準備
- 入力: ウィッシュリストスラッグ、カテゴリID、ランキングパラメータ
- 出力: サブスクリプションコンテキストと検証されたパラメータ付きウィッシュリストデータ
- 依存関係: ウィッシュリストリポジトリ、サマリーカテゴリリポジトリ、サブスクリプション検証
- 外部サービス: データベースクラスター、サブスクリプションサービス
ステップ3: サブスクリプションフィルタリング・データ処理
- 説明: サブスクリプションベースフィルタリングを適用し、アナライザーデータベースからランキングデータを取得
- アクション: サブスクリプション日付フィルタ適用、ランキングデータクエリ、最新クロールデータ処理
- 入力: サブスクリプション日付、カテゴリランキングID、クエリパラメータ
- 出力: サブスクリプション準拠付きフィルタリングされたランキングデータ
- 依存関係: ランキングリポジトリ、サブスクリプションフィルタリング、日付処理
- 外部サービス: アナライザーデータベース、サブスクリプション検証サービス
ステップ4: データフォーマット・レスポンス生成
- 説明: ページネーションと適切な構造付きのAPIレスポンス用にランキングデータをフォーマット
- アクション: データをAPI形式に変換、ページネーション適用、レスポンス構造生成
- 入力: ランキングデータ、ページネーションパラメータ、レスポンス形式要件
- 出力: ページネーションとメタデータ付きのフォーマットされたAPIレスポンス
- 依存関係: データ変換サービス、ページネーション処理、レスポンスフォーマット
- 外部サービス: APIレスポンスサービス、データシリアライゼーション
データベース関連テーブル・フィールド
データベース: gb_console, gb_analyzer
erDiagram
"gb_console.wishlist_to_groups" {
bigint id PK
string name "ウィッシュリストの名前"
string slug "ウィッシュリストのスラッグ"
integer status "0: 非アクティブ, 1: アクティブ, 3: キャンセル"
}
"gb_analyzer.category_rankings" {
bigint id PK
string mall_category_id
string mall_category_name
integer mall_id
}
"gb_analyzer.product_category_rankings" {
bigint id PK
bigint category_ranking_id FK
integer ranking
string mall_product_id
string product_name
double price
string shop_name
text image
text product_url
text shop_url
integer mall_id
}
"gb_analyzer.product_category_rankings" }|--|| "gb_analyzer.category_rankings" : "所属"
ケースドキュメント
ケース1: カテゴリランキング分析
API: トップカテゴリランキング
シーケンス図
sequenceDiagram
participant Client
participant Controller as ProductCategoryRankingController
participant Service as ProductCategoryRankingService
participant WishlistRepo as WishlistToGroupRepository
participant SummaryRepo as SummaryWishlistCategoryRepository
participant RankingRepo as ProductCategoryRankingRepository
participant Database
Note over Client,Database: カテゴリランキング分析フロー
rect rgb(255, 255, 200)
Note right of Client: 認証フェーズ
Client->>Controller: GET /api/v1/wishlist-to-group/{slug}/top-category-ranking
Controller->>Controller: ユーザー認証
end
rect rgb(200, 230, 255)
Note right of Controller: 検証フェーズ
Controller->>WishlistRepo: findBySlug(slug)
WishlistRepo->>Database: wishlist_to_groupsからSELECT
Database-->>WishlistRepo: ウィッシュリストレコード
Controller->>Controller: category_idパラメータ検証
end
rect rgb(200, 255, 255)
Note right of Controller: サービス処理
Controller->>Service: serverPaginationFilteringFor(params, wishlist)
Service->>Service: サブスクリプションデータ読み込み
Service->>SummaryRepo: getByCategoryId(categoryId)
SummaryRepo->>Database: カテゴリデータSELECT
Database-->>SummaryRepo: カテゴリレコード
end
rect rgb(255, 230, 200)
Note right of Service: ランキングデータ取得
Service->>Service: カテゴリ用一意キー生成
Service->>RankingRepo: unique_keyでカテゴリランキング検索
Service->>RankingRepo: 最新crawl_created_at取得
Service->>RankingRepo: サブスクリプションフィルタ付きクエリ
RankingRepo->>Database: サブスクリプション日付フィルタ付きSELECT
Database-->>RankingRepo: ランキングレコード
end
rect rgb(200, 255, 200)
Note right of Service: 成功レスポンス
Service->>Service: ページネーション適用
Service-->>Controller: ページネーションランキング
Controller->>Controller: リソースに変換
Controller-->>Client: ランキング付きJSONレスポンス
end
ステップ
- 認証: ユーザーセッションを検証
- ウィッシュリスト検証: スラッグでウィッシュリストを検索し存在を検証
- パラメータ検証: 必須のcategory_idパラメータを検証
- サービス処理: サブスクリプションデータとカテゴリ情報を読み込み
- ランキング取得: 一意キーを生成しサブスクリプションフィルタ付きランキングデータをクエリ
- レスポンス生成: ページネーションを適用しAPIリソースに変換
エラーハンドリング
- 401 Unauthorized: 無効な認証
- 404 Not Found: ウィッシュリストが見つからない
- 400 Bad Request: category_idパラメータが欠落または無効
- 500 Internal Server Error: データベースまたはシステムエラー
ケース2: 検索クエリランキング分析
API: トップ検索ランキング
シーケンス図
sequenceDiagram
participant Client
participant Controller as ProductSearchQueryRankingController
participant Service as ProductSearchQueryRankingService
participant WishlistRepo as WishlistToGroupRepository
participant RankingRepo as ProductSearchQueryRankingRepository
participant Database
Note over Client,Database: 検索クエリランキング分析フロー
rect rgb(255, 255, 200)
Note right of Client: 認証フェーズ
Client->>Controller: GET /api/v1/wishlist-to-group/{slug}/top-search-ranking
Controller->>Controller: ユーザー認証
end
rect rgb(200, 230, 255)
Note right of Controller: 検証フェーズ
Controller->>WishlistRepo: findBySlug(slug)
WishlistRepo->>Database: wishlist_to_groupsからSELECT
Database-->>WishlistRepo: ウィッシュリストレコード
Controller->>Controller: 検索パラメータ検証
end
rect rgb(200, 255, 255)
Note right of Controller: サービス処理
Controller->>Service: serverPaginationFilteringFor(params, wishlist)
Service->>Service: サブスクリプションデータ読み込み
Service->>Service: 検索クエリパラメータ検証
end
rect rgb(255, 230, 200)
Note right of Service: 検索ランキング取得
Service->>RankingRepo: 検索ランキングクエリ
Service->>RankingRepo: サブスクリプションフィルタ適用
Service->>RankingRepo: 最新クロールデータ取得
RankingRepo->>Database: フィルタ付きSELECT
Database-->>RankingRepo: 検索ランキングレコード
end
rect rgb(200, 255, 200)
Note right of Service: 成功レスポンス
Service->>Service: ページネーション適用
Service-->>Controller: ページネーション検索ランキング
Controller->>Controller: リソースに変換
Controller-->>Client: 検索ランキング付きJSONレスポンス
end
ステップ
- 認証: ユーザーセッションを検証
- ウィッシュリスト検証: スラッグでウィッシュリストを検索し存在を検証
- パラメータ検証: 検索クエリパラメータを検証
- サービス処理: サブスクリプションデータと検索パラメータを読み込み
- 検索ランキング取得: サブスクリプションフィルタ付き検索ランキングデータをクエリ
- レスポンス生成: ページネーションを適用しAPIリソースに変換
エラーハンドリング
- 401 Unauthorized: 無効な認証
- 404 Not Found: ウィッシュリストが見つからない
- 400 Bad Request: 無効な検索パラメータ
- 500 Internal Server Error: データベースまたはシステムエラー