get_top_article.py 922 B

1234567891011121314151617181920212223242526272829
  1. from .base import BaseStrategy
  2. class GetTopArticleStrategy(BaseStrategy):
  3. @staticmethod
  4. def base() -> str:
  5. query = """
  6. SELECT title, sum(view_count) as total_view_count, sum(fans) as total_fan_count
  7. FROM datastat_sort_strategy
  8. WHERE position = 1 and gh_id = %s AND date_str >= '20250501' AND view_count > 1000
  9. GROUP BY title
  10. ORDER BY sum(view_count) / sum(fans) DESC
  11. LIMIT 25;
  12. """
  13. return query
  14. @staticmethod
  15. def strategy_v1() -> str:
  16. query = """
  17. SELECT date_str, title, view_count from datastat_sort_strategy where position = 1 and gh_id = %s
  18. """
  19. return query
  20. @staticmethod
  21. def strategy_v2() -> str:
  22. query = """
  23. SELECT date_str, title, view_count from datastat_sort_strategy where position = 1 and gh_id = %s
  24. """
  25. return query