Files
ewoooc/database/ppt_reports.py
ogt 4f4e7ef062
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
feat: 實作 PPT 簡報資料庫持久化機制
- 新增 PPTReport 模型,支援快取查詢結果和檔案路徑
- 實作 growth/vendor/bcg 三種報告的快取機制
- 24 小時過期設定,避免重複計算
- 自動清理過期快取記錄

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 22:59:04 +08:00

29 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
PPT 簡報資料庫持久化模型
用於儲存生成的簡報,避免重複計算
"""
from sqlalchemy import Column, Integer, String, DateTime, Text, Float
from sqlalchemy.orm import declarative_base
from datetime import datetime
Base = declarative_base()
class PPTReport(Base):
"""PPT 簡報記錄表"""
__tablename__ = 'ppt_reports'
id = Column(Integer, primary_key=True)
report_type = Column(String(50), nullable=False, index=True) # growth/vendor/bcg
parameters = Column(Text) # JSON 字串,記錄查詢參數
file_path = Column(String(500)) # 生成檔案路徑
file_size = Column(Integer) # 檔案大小
generated_at = Column(DateTime, default=datetime.now, index=True)
expires_at = Column(DateTime, index=True) # 過期時間
# 資料快取JSON 字串)
cached_data = Column(Text) # 儲存查詢結果,避免重複計算
def __repr__(self):
return f"<PPTReport(type={self.report_type}, params={self.parameters}, generated_at={self.generated_at})>"