diff --git a/app/enum/action_type.py b/app/enum/action_type.py index 2fbec69..667e3de 100644 --- a/app/enum/action_type.py +++ b/app/enum/action_type.py @@ -1,7 +1,9 @@ from enum import Enum + class ActionType(Enum): - CLICK = 1 - LIKE = 2 - WATCH = 3 - RATING = 4 \ No newline at end of file + CLICK = 1 + LIKE = 2 + WATCH = 3 + RATING = 4 + DISLIKE = 5 diff --git a/app/services/weight_strategy.py b/app/services/weight_strategy.py index 5a6474e..b7753b3 100644 --- a/app/services/weight_strategy.py +++ b/app/services/weight_strategy.py @@ -1,25 +1,28 @@ from app.enum.action_type import ActionType -def convert_to_weight(type : ActionType, value : float) -> float : - if type == ActionType.CLICK: - return 0.05 - if type == ActionType.LIKE: - return 0.1 - if type == ActionType.WATCH: - if 30 <= value <= 50: - return 0.1 - if 50 <= value <= 70: - return 0.2 - if 70 <= value: - return 0.3 - else: - return 0 - if type == ActionType.RATING: - if value <= 2: - return 0 - if value == 3: - return 0.2 - if value == 4: - return 0.3 - if value == 5: - return 0.4 + +def convert_to_weight(type: ActionType, value: float) -> float: + if type == ActionType.CLICK: + return 0.05 + if type == ActionType.LIKE: + return 0.1 + if type == ActionType.WATCH: + if 30 <= value <= 50: + return 0.1 + if 50 <= value <= 70: + return 0.2 + if 70 <= value: + return 0.3 + else: + return 0 + if type == ActionType.RATING: + if value <= 2: + return 0 + if value == 3: + return 0.2 + if value == 4: + return 0.3 + if value == 5: + return 0.4 + if type == ActionType.DISLIKE: + return -0.1