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