async_mysql_utils.py 657 B

123456789101112131415161718192021
  1. from typing import List, Dict
  2. async def get_top_article_title_list(pool) -> List[Dict]:
  3. query = """
  4. select distinct title, source_id
  5. from datastat_sort_strategy
  6. where produce_plan_name = %s and source_id is not null;
  7. """
  8. return await pool.async_fetch(query=query, params=("TOP100",))
  9. async def get_hot_titles(pool, date_string) -> List[Dict]:
  10. """get titles of hot articles"""
  11. query = """
  12. select distinct title
  13. from datastat_sort_strategy
  14. where position < %s and read_rate >= %s and date_str >= %s;
  15. """
  16. return await pool.async_fetch(query=query, params=(3, 1.21, date_string))