From d56cf1ae94f657da23a7497b493dca8b03d88256 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Sat, 5 Nov 2022 21:41:33 +0100 Subject: [PATCH] TagTreeElement.shareScore: Filter tags for score sharing by use_for_preferences --- server/entertainment_decider/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/entertainment_decider/models.py b/server/entertainment_decider/models.py index d38820a..3dd48bd 100644 --- a/server/entertainment_decider/models.py +++ b/server/entertainment_decider/models.py @@ -169,13 +169,14 @@ class TagTreeElement: children: List[TagTreeElement] = dataclasses.field(default_factory=lambda: []) def share_score(self, points: float) -> PreferenceScoreAppender: - if len(self.children) <= 0: + children = [elem for elem in self.children if elem.base.use_for_preferences] + if len(children) <= 0: return PreferenceScoreAppender(PreferenceScore({self.base: points})) - children_fraction = len(self.children) + children_fraction = len(children) base_fraction = children_fraction + 1 single_share = points / (base_fraction + children_fraction) base_share = PreferenceScore({self.base: single_share * base_fraction}) - shares = (child.share_score(single_share) for child in self.children) + shares = (child.share_score(single_share) for child in children) return base_share & shares