feat(insta): _bg_extract uses preferences + 09:00 trends_collect cron
This commit is contained in:
@@ -29,6 +29,12 @@ async def _run_insta_schedule():
|
|||||||
if agent:
|
if agent:
|
||||||
await agent.on_schedule()
|
await agent.on_schedule()
|
||||||
|
|
||||||
|
|
||||||
|
async def _run_insta_trends_collect():
|
||||||
|
agent = AGENT_REGISTRY.get("insta")
|
||||||
|
if agent:
|
||||||
|
await agent.on_command("collect_trends", {})
|
||||||
|
|
||||||
async def _run_lotto_schedule():
|
async def _run_lotto_schedule():
|
||||||
agent = AGENT_REGISTRY.get("lotto")
|
agent = AGENT_REGISTRY.get("lotto")
|
||||||
if agent:
|
if agent:
|
||||||
@@ -68,6 +74,7 @@ def init_scheduler():
|
|||||||
id="stock_ai_news_sentiment",
|
id="stock_ai_news_sentiment",
|
||||||
)
|
)
|
||||||
scheduler.add_job(_run_insta_schedule, "cron", hour=9, minute=30, id="insta_pipeline")
|
scheduler.add_job(_run_insta_schedule, "cron", hour=9, minute=30, id="insta_pipeline")
|
||||||
|
scheduler.add_job(_run_insta_trends_collect, "cron", hour=9, minute=0, id="insta_trends_collect")
|
||||||
scheduler.add_job(_run_lotto_schedule, "cron", day_of_week="mon", hour=9, minute=0, id="lotto_curate")
|
scheduler.add_job(_run_lotto_schedule, "cron", day_of_week="mon", hour=9, minute=0, id="lotto_curate")
|
||||||
scheduler.add_job(_run_youtube_research, "cron", hour=9, minute=0, id="youtube_research")
|
scheduler.add_job(_run_youtube_research, "cron", hour=9, minute=0, id="youtube_research")
|
||||||
scheduler.add_job(_send_youtube_weekly_report, "cron", day_of_week="mon", hour=8, minute=0, id="youtube_weekly_report")
|
scheduler.add_job(_send_youtube_weekly_report, "cron", day_of_week="mon", hour=8, minute=0, id="youtube_weekly_report")
|
||||||
|
|||||||
@@ -99,11 +99,16 @@ class ExtractRequest(BaseModel):
|
|||||||
categories: Optional[list[str]] = None
|
categories: Optional[list[str]] = None
|
||||||
|
|
||||||
|
|
||||||
async def _bg_extract(task_id: str, categories: list[str]):
|
async def _bg_extract(task_id: str, categories: Optional[list[str]] = None):
|
||||||
try:
|
try:
|
||||||
db.update_task(task_id, "processing", 10, "추출 중")
|
db.update_task(task_id, "processing", 10, "추출 중")
|
||||||
for cat in categories:
|
prefs_rows = db.get_preferences()
|
||||||
keyword_extractor.extract_for_category(cat, limit=KEYWORDS_PER_CATEGORY)
|
weights = {p["category"]: p["weight"] for p in prefs_rows}
|
||||||
|
if categories:
|
||||||
|
# 사용자가 카테고리 명시한 경우만 그 서브셋으로 균등 가중치 (override)
|
||||||
|
weights = {c: 1.0 for c in categories}
|
||||||
|
total = KEYWORDS_PER_CATEGORY * max(1, len([w for w in weights.values() if w > 0]))
|
||||||
|
keyword_extractor.extract_with_weights(weights, total_limit=total)
|
||||||
db.update_task(task_id, "succeeded", 100, "완료", result_id=0)
|
db.update_task(task_id, "succeeded", 100, "완료", result_id=0)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("extract failed")
|
logger.exception("extract failed")
|
||||||
|
|||||||
Reference in New Issue
Block a user