Biểu đồ Đánh giá (Review Chart)

Mô tả Tổng quan

Endpoint Biểu đồ Đánh giá trả về chuỗi thời gian số lượng đánh giá theo thời gian cho các sản phẩm đã chọn. Hỗ trợ 2 chế độ xử lý: Quan điểm AI và Quan điểm Cụ thể (SPVP). Cả hai chế độ đều trả về số tích lũy theo thời gian và kèm chi tiết sản phẩm cho mỗi điểm dữ liệu.

Sơ đồ Hoạt động

---
config:
  theme: base
  layout: dagre
  flowchart:
    curve: linear
    htmlLabels: true
  themeVariables:
    edgeLabelBackground: "transparent"
---
flowchart TB
    Client[Client Application]
    API[ProductAnalyzerController]
    Dataset[Dataset Validation]
    AService[ProductAnalyzerService]
    SService[SpvpService]
    Database[(Database)]
    
    Client --- 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'>Gửi yêu cầu GET</p>
        </div>
    ]
    Step1 --> API

    API --- 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'>Xác thực Dataset</p>
        </div>
    ]
    Step2 --> Dataset

    Dataset --- 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'>Xử lý tham số</p>
        </div>
    ]
    Step3 --> API

    API --- Step4A[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #99cc66 !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>4A</span>
            <p style='margin-top: 8px'>Quan điểm AI</p>
        </div>
    ]
    Step4A --> AService
    AService --> Database
    Database --> AService

    API --- Step4B[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #cc66cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>4B</span>
            <p style='margin-top: 8px'>Quan điểm Cụ thể</p>
        </div>
    ]
    Step4B --> SService
    SService --> Database
    Database --> SService

    AService --- Step5A[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #99cc66 !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>5A</span>
            <p style='margin-top: 8px'>Định dạng phản hồi</p>
        </div>
    ]
    SService --- Step5B[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #cc66cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>5B</span>
            <p style='margin-top: 8px'>Định dạng phản hồi</p>
        </div>
    ]
    Step5A --> API
    Step5B --> API

    API --- 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'>Trả về JSON</p>
        </div>
    ]
    Step6 --> Client
    
    %% Styling
    style Client fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style API fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style Dataset fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style AService fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style SService fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style Database fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
    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 Step4A fill:transparent,stroke:transparent,stroke-width:1px
    style Step4B fill:transparent,stroke:transparent,stroke-width:1px
    style Step5A fill:transparent,stroke:transparent,stroke-width:1px
    style Step5B fill:transparent,stroke:transparent,stroke-width:1px
    style Step6 fill:transparent,stroke:transparent,stroke-width:1px

Swagger Link

API: Review Chart API

Endpoint

  • GET /api/v1/general/analysis/{wldh_slug}/review-chart

Tham số truy vấn

Tham số Kiểu Bắt buộc Mô tả
product_ids array Danh sách ID sản phẩm cần phân tích
viewpoint_type string Kiểu quan điểm (ai hoặc spvp)
viewpoint_id string Điều kiện ID quan điểm (chế độ SPVP)
start_date string Không Ngày bắt đầu (YYYY-MM-DD)
end_date string Không Ngày kết thúc (YYYY-MM-DD)
group_by string Không Đơn vị nhóm (day, week, month)

Định dạng phản hồi

Chế độ Quan điểm AI

{
  "success": true,
  "data": {
    "series": [
      {
        "product_id": "prod123",
        "product_name": "Tên sản phẩm",
        "product_image": "https://example.com/image.jpg",
        "data": [
          { "date": "2024-01-01", "count": 10, "cumulative": 10 },
          { "date": "2024-01-02", "count": 15, "cumulative": 25 }
        ]
      }
    ],
    "metadata": {
      "total_products": 1,
      "date_range": { "start": "2024-01-01", "end": "2024-01-31" }
    }
  }
}

Chế độ Quan điểm Cụ thể (SPVP)

{
  "success": true,
  "data": {
    "series": [
      {
        "product_id": "prod123",
        "product_name": "Tên sản phẩm",
        "product_image": "https://example.com/image.jpg",
        "viewpoint_id": "vp456",
        "viewpoint_name": "Tên quan điểm",
        "data": [
          { "date": "2024-01-01", "count": 8, "cumulative": 8 },
          { "date": "2024-01-02", "count": 12, "cumulative": 20 }
        ]
      }
    ],
    "metadata": {
      "total_products": 1,
      "date_range": { "start": "2024-01-01", "end": "2024-01-31" }
    }
  }
}

Xử lý Lỗi

Thông điệp Mô tả
400 Bad Request Tham số không hợp lệ
404 Dataset not found Không tìm thấy dataset
422 Validation failed Lỗi xác thực
500 Internal server error Lỗi máy chủ

Ví dụ sử dụng

Lấy biểu đồ theo Quan điểm AI

curl -X GET "https://api.example.com/api/v1/general/analysis/dataset-slug/review-chart?product_ids[]=prod123&product_ids[]=prod456&viewpoint_type=ai&start_date=2024-01-01&end_date=2024-01-31&group_by=day"

Lấy biểu đồ theo Quan điểm Cụ thể

curl -X GET "https://api.example.com/api/v1/general/analysis/dataset-slug/review-chart?product_ids[]=prod123&viewpoint_type=spvp&viewpoint_id=vp456&start_date=2024-01-01&end_date=2024-01-31&group_by=week"

Ghi chú xử lý dữ liệu

Tính tích lũy

  • Mỗi ngày biểu thị số lượng review và tổng tích lũy đến ngày đó
  • Dữ liệu thiếu được coi là 0 để đảm bảo chuỗi thời gian nhất quán

Tùy chọn nhóm

  • day: Nhóm theo ngày
  • week: Nhóm theo tuần (bắt đầu thứ Hai)
  • month: Nhóm theo tháng

Tối ưu hiệu năng

  • Với dataset lớn, nên giới hạn phạm vi ngày
  • Nếu có nhiều sản phẩm, nên giới hạn số sản phẩm mỗi lần phân tích