Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ab034d3c15 | |||
| 973c440a8a |
@@ -63,6 +63,12 @@ def _device_marketing_name(model: str | None) -> str | None:
|
|||||||
return _DEVICE_MARKETING_NAMES.get(model.strip().upper())
|
return _DEVICE_MARKETING_NAMES.get(model.strip().upper())
|
||||||
|
|
||||||
|
|
||||||
|
def _attach_comparison_device_details(items: list[ComparisonRecord]) -> None:
|
||||||
|
"""给比价记录补充可读机型名,同时保留原始设备编码。"""
|
||||||
|
for item in items:
|
||||||
|
item.device_model_name = _device_marketing_name(item.device_model)
|
||||||
|
|
||||||
|
|
||||||
def _attach_feedback_device_details(db: Session, feedbacks: list[Feedback]) -> None:
|
def _attach_feedback_device_details(db: Session, feedbacks: list[Feedback]) -> None:
|
||||||
"""按同一用户、同一设备编码及提交时间补齐厂商和 ROM 大版本。"""
|
"""按同一用户、同一设备编码及提交时间补齐厂商和 ROM 大版本。"""
|
||||||
candidates = [
|
candidates = [
|
||||||
@@ -344,6 +350,7 @@ def list_comparison_records(
|
|||||||
limit=limit, cursor=cursor,
|
limit=limit, cursor=cursor,
|
||||||
)
|
)
|
||||||
_attach_user_info(db, items)
|
_attach_user_info(db, items)
|
||||||
|
_attach_comparison_device_details(items)
|
||||||
# 「本次比价看广告的预估收益」:按本页 trace_id 一次性聚合(同 _attach_user_info 逐页范式)。
|
# 「本次比价看广告的预估收益」:按本页 trace_id 一次性聚合(同 _attach_user_info 逐页范式)。
|
||||||
# ad_revenue_yuan 非 ORM 列,仅瞬态挂实例上供 AdminComparisonListItem(from_attributes)读出。
|
# ad_revenue_yuan 非 ORM 列,仅瞬态挂实例上供 AdminComparisonListItem(from_attributes)读出。
|
||||||
rev = ad_ecpm.revenue_yuan_by_trace(db, [it.trace_id for it in items])
|
rev = ad_ecpm.revenue_yuan_by_trace(db, [it.trace_id for it in items])
|
||||||
@@ -490,6 +497,7 @@ def get_comparison_record(db: Session, record_id: int) -> ComparisonRecord | Non
|
|||||||
rec = db.get(ComparisonRecord, record_id)
|
rec = db.get(ComparisonRecord, record_id)
|
||||||
if rec is not None:
|
if rec is not None:
|
||||||
_attach_user_info(db, [rec])
|
_attach_user_info(db, [rec])
|
||||||
|
_attach_comparison_device_details([rec])
|
||||||
return rec
|
return rec
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,10 @@ class AdminComparisonListItem(BaseModel):
|
|||||||
# 本次比价 LLM 总成本(元,按当时价冻结);旧记录/未回填为 None → 前端「成本」列回退估算。见 services/llm_cost.py。
|
# 本次比价 LLM 总成本(元,按当时价冻结);旧记录/未回填为 None → 前端「成本」列回退估算。见 services/llm_cost.py。
|
||||||
llm_cost_yuan: float | None = None
|
llm_cost_yuan: float | None = None
|
||||||
device_model: str | None = None
|
device_model: str | None = None
|
||||||
|
device_model_name: str | None = None
|
||||||
rom_vendor: str | None = None
|
rom_vendor: str | None = None
|
||||||
rom_name: str | None = None
|
rom_name: str | None = None
|
||||||
|
rom_version: int | None = None
|
||||||
android_version: str | None = None
|
android_version: str | None = None
|
||||||
app_version: str | None = None
|
app_version: str | None = None
|
||||||
ad_revenue_yuan: float = 0.0 # 本次比价看的信息流广告预估收益(元),queries 瞬态挂 ORM 实例上
|
ad_revenue_yuan: float = 0.0 # 本次比价看的信息流广告预估收益(元),queries 瞬态挂 ORM 实例上
|
||||||
@@ -84,7 +86,6 @@ class AdminComparisonDetail(AdminComparisonListItem):
|
|||||||
skipped_dish_names: list = []
|
skipped_dish_names: list = []
|
||||||
# 全量环境
|
# 全量环境
|
||||||
device_manufacturer: str | None = None
|
device_manufacturer: str | None = None
|
||||||
rom_version: int | None = None
|
|
||||||
android_sdk: int | None = None
|
android_sdk: int | None = None
|
||||||
app_version_code: int | None = None
|
app_version_code: int | None = None
|
||||||
source_app_version: str | None = None
|
source_app_version: str | None = None
|
||||||
|
|||||||
@@ -593,6 +593,53 @@ def test_withdraw_summary_counts_match_status_lists_by_source(
|
|||||||
).status_code == 422
|
).status_code == 422
|
||||||
|
|
||||||
|
|
||||||
|
def test_comparison_records_show_readable_device_and_rom_version(
|
||||||
|
admin_client: TestClient, admin_token: str
|
||||||
|
) -> None:
|
||||||
|
db = SessionLocal()
|
||||||
|
try:
|
||||||
|
user = user_repo.upsert_user_for_login(
|
||||||
|
db, phone="13800009041", register_channel="sms"
|
||||||
|
)
|
||||||
|
record = ComparisonRecord(
|
||||||
|
user_id=user.id,
|
||||||
|
trace_id="comparison-readable-device",
|
||||||
|
status="success",
|
||||||
|
device_model="V2166BA",
|
||||||
|
device_manufacturer="vivo",
|
||||||
|
rom_vendor="vivo",
|
||||||
|
rom_name="OriginOS",
|
||||||
|
rom_version=4,
|
||||||
|
android_version="14",
|
||||||
|
)
|
||||||
|
db.add(record)
|
||||||
|
db.commit()
|
||||||
|
record_id = record.id
|
||||||
|
user_id = user.id
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
response = admin_client.get(
|
||||||
|
"/admin/api/comparison-records",
|
||||||
|
params={"user_id": user_id},
|
||||||
|
headers=_auth(admin_token),
|
||||||
|
)
|
||||||
|
assert response.status_code == 200, response.text
|
||||||
|
item = response.json()["items"][0]
|
||||||
|
assert item["device_model"] == "V2166BA"
|
||||||
|
assert item["device_model_name"] == "vivo Y77e"
|
||||||
|
assert item["rom_name"] == "OriginOS"
|
||||||
|
assert item["rom_version"] == 4
|
||||||
|
|
||||||
|
detail = admin_client.get(
|
||||||
|
f"/admin/api/comparison-records/{record_id}",
|
||||||
|
headers=_auth(admin_token),
|
||||||
|
)
|
||||||
|
assert detail.status_code == 200, detail.text
|
||||||
|
assert detail.json()["device_model_name"] == "vivo Y77e"
|
||||||
|
assert detail.json()["rom_version"] == 4
|
||||||
|
|
||||||
|
|
||||||
def test_ad_coin_audit_full_count_truncate_and_only_mismatch(
|
def test_ad_coin_audit_full_count_truncate_and_only_mismatch(
|
||||||
admin_client: TestClient, admin_token: str
|
admin_client: TestClient, admin_token: str
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user