12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- """
- @author luojunhui
- @description: find top fission / read oss path list
- """
- from applications.const import server_const
- from applications.match_algorithm import get_content_id_fission_info
- from applications.match_algorithm import get_history_content_ids
- class OssRank:
- """
- input: content_id
- output: find the top fission / read oss path list
- """
- def __init__(self, db_client, params):
- self.db_client = db_client
- self.params = params
- self.content_id = None
- async def check_params(self):
- """
- check params
- """
- try:
- self.content_id = self.params['contentId']
- self.video_limit = self.params.get("videoLimit", server_const.VIDEO_LIMIT)
- return
- except KeyError as e:
- result = {
- "error": str(e),
- "message": "invalid params",
- "data": self.params,
- "code": server_const.PARAMS_CHECK_FAILED_CODE
- }
- return result
-
- async def deal(self):
- """
- entrance of this class
- """
- params_error = await self.check_params()
- if params_error:
- return params_error
- else:
- history_content_tuple = await get_history_content_ids(
- content_id=self.content_id,
- db_client=self.db_client
- )
-
- if history_content_tuple:
- oss_path_result = await get_content_id_fission_info(
- content_id_tuple=history_content_tuple,
- db_client=self.db_client,
- video_limit=self.video_limit
- )
- if oss_path_result:
- oss_path_list = [
- {
- "video_oss_path": i['oss_name'],
- "fission_0_on_read": i['fission_0_on_read'],
- "uid": server_const.RE_RANK_UID
- }
- for i in oss_path_result
- ]
- code = server_const.SUCCESS_CODE
- else:
- oss_path_list = []
- code = server_const.FAIL_CODE
-
- return {
- "oss_path_list": oss_path_list,
- "code": code
- }
- else:
- return {
- "oss_path_list": [],
- "code": server_const.FAIL_CODE
- }
|