#!/usr/bin/env python3 import sys from pathlib import Path from datetime import datetime PROJECT_ROOT = Path(__file__).parent.parent sys.path.insert(0, str(PROJECT_ROOT)) sys.path.insert(0, str(PROJECT_ROOT / 'platform' / 'backend')) from db_helper import get_topic_by_id from app.database import SessionLocal from app.models import Topic as DBTopic def adjust_db_priority(adjustments): updated = [] db = SessionLocal() try: for tid, new_score in adjustments.items(): topic = db.query(DBTopic).filter(DBTopic.id == tid).first() if topic: old = topic.priority_score topic.priority_score = new_score topic.updated_at = datetime.now() updated.append(f"{tid}: {old} -> {new_score}") db.commit() finally: db.close() return updated def main(): adjustments = {'D01': 11, 'B05': 10} print("调整优先级...") updated = adjust_db_priority(adjustments) if updated: print("[DB] updated:", ', '.join(updated)) print("完成") if __name__ == "__main__": main()