aigc_system_database.py 762 B

1234567891011121314151617181920
  1. from datetime import datetime, timedelta
  2. async def get_titles_from_produce_plan(pool, plan_id, threshold=None):
  3. if not threshold:
  4. fifteen_days_ago = datetime.now() - timedelta(days=30)
  5. threshold = fifteen_days_ago.strftime("%Y%m%d") + 15 * "0"
  6. query = f"""
  7. select distinct t2.title
  8. from produce_plan_input_source t3
  9. join crawler_plan_result_rel t1 on t3.input_source_value = t1.plan_id
  10. join crawler_content t2 on t1.channel_source_id = t2.channel_content_id
  11. where t3.plan_id = %s
  12. and t3.input_source_value > %s;
  13. """
  14. response = await pool.async_fetch(
  15. query=query, db_name="aigc", params=(plan_id, threshold)
  16. )
  17. return tuple([i["title"] for i in response])