feat(recommend): add job to refresh recommend cache

This commit is contained in:
InfinityPacer
2024-12-23 01:32:17 +08:00
parent 60bcc802cf
commit a5d6062aa8
2 changed files with 21 additions and 1 deletions
+2 -1
View File
@@ -62,6 +62,7 @@ class RecommendChain(ChainBase, metaclass=Singleton):
self.tmdb_tvs() self.tmdb_tvs()
self.tmdb_trending() self.tmdb_trending()
self.bangumi_calendar() self.bangumi_calendar()
self.douban_movie_showing()
self.douban_movies() self.douban_movies()
self.douban_tvs() self.douban_tvs()
self.douban_movie_top250() self.douban_movie_top250()
@@ -88,7 +89,7 @@ class RecommendChain(ChainBase, metaclass=Singleton):
@log_execution_time(logger=logger) @log_execution_time(logger=logger)
@cached_with_empty_check @cached_with_empty_check
def tmdb_tvs(self, sort_by: str = "popularity.desc", with_genres: str = "", def tmdb_tvs(self, sort_by: str = "popularity.desc", with_genres: str = "",
with_original_language: str = "", page: int = 1) -> Any: with_original_language: str = "zh|en|ja|ko", page: int = 1) -> Any:
""" """
TMDB热门电视剧 TMDB热门电视剧
""" """
+19
View File
@@ -11,6 +11,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
from app import schemas from app import schemas
from app.chain import ChainBase from app.chain import ChainBase
from app.chain.mediaserver import MediaServerChain from app.chain.mediaserver import MediaServerChain
from app.chain.recommend import RecommendChain
from app.chain.site import SiteChain from app.chain.site import SiteChain
from app.chain.subscribe import SubscribeChain from app.chain.subscribe import SubscribeChain
from app.chain.tmdb import TmdbChain from app.chain.tmdb import TmdbChain
@@ -121,6 +122,11 @@ class Scheduler(metaclass=Singleton):
"name": "站点数据刷新", "name": "站点数据刷新",
"func": SiteChain().refresh_userdatas, "func": SiteChain().refresh_userdatas,
"running": False, "running": False,
},
"recommend_refresh": {
"name": "推荐缓存",
"func": RecommendChain().refresh_recommend,
"running": False,
} }
} }
@@ -310,6 +316,19 @@ class Scheduler(metaclass=Singleton):
} }
) )
# 推荐缓存
self._scheduler.add_job(
self.start,
"interval",
id="recommend_refresh",
name="推荐缓存",
hours=6,
next_run_time=datetime.now(pytz.timezone(settings.TZ)) + timedelta(seconds=3),
kwargs={
'job_id': 'recommend_refresh'
}
)
self.init_plugin_jobs() self.init_plugin_jobs()
# 打印服务 # 打印服务