@@ -28,7 +28,6 @@ class TargetDict(TypedDict):
2828 image_base64 : str
2929 active_flag : bool
3030 processing_time_seconds : int | float
31- processed_tracking_rating : int
3231 application_metadata : str | None
3332 target_id : str
3433 last_modified_date : str
@@ -51,13 +50,6 @@ def _time_now() -> datetime.datetime:
5150 return datetime .datetime .now (tz = gmt )
5251
5352
54- def _random_tracking_rating () -> int :
55- """
56- Return a random tracking rating.
57- """
58- return random .randint (0 , 5 )
59-
60-
6153@dataclass (frozen = True , eq = True )
6254class Target :
6355 """
@@ -75,14 +67,18 @@ class Target:
7567 delete_date : datetime .datetime | None = None
7668 last_modified_date : datetime .datetime = field (default_factory = _time_now )
7769 previous_month_recos : int = 0
78- processed_tracking_rating : int = field (
79- default_factory = _random_tracking_rating ,
80- )
8170 reco_rating : str = ""
8271 target_id : str = field (default_factory = _random_hex )
8372 total_recos : int = 0
8473 upload_date : datetime .datetime = field (default_factory = _time_now )
8574
75+ @staticmethod
76+ def _tracking_rater (image_content : bytes ) -> int :
77+ """
78+ Return a random tracking rating.
79+ """
80+ return random .randint (0 , 5 )
81+
8682 @property
8783 def _post_processing_status (self ) -> TargetStatuses :
8884 """
@@ -158,7 +154,7 @@ def tracking_rating(self) -> int:
158154 return - 1
159155
160156 if self ._post_processing_status == TargetStatuses .SUCCESS :
161- return self .processed_tracking_rating
157+ return self ._tracking_rater ( image_content = self . image_value )
162158
163159 return 0
164160
@@ -173,7 +169,6 @@ def from_dict(cls, target_dict: TargetDict) -> Target:
173169 width = target_dict ["width" ]
174170 image_base64 = target_dict ["image_base64" ]
175171 image_value = base64 .b64decode (image_base64 )
176- processed_tracking_rating = target_dict ["processed_tracking_rating" ]
177172 processing_time_seconds = target_dict ["processing_time_seconds" ]
178173 application_metadata = target_dict ["application_metadata" ]
179174 target_id = target_dict ["target_id" ]
@@ -202,7 +197,6 @@ def from_dict(cls, target_dict: TargetDict) -> Target:
202197 delete_date = delete_date ,
203198 last_modified_date = last_modified_date ,
204199 upload_date = upload_date ,
205- processed_tracking_rating = processed_tracking_rating ,
206200 )
207201
208202 def to_dict (self ) -> TargetDict :
@@ -221,7 +215,6 @@ def to_dict(self) -> TargetDict:
221215 "image_base64" : image_base64 ,
222216 "active_flag" : self .active_flag ,
223217 "processing_time_seconds" : self .processing_time_seconds ,
224- "processed_tracking_rating" : self .processed_tracking_rating ,
225218 "application_metadata" : self .application_metadata ,
226219 "target_id" : self .target_id ,
227220 "last_modified_date" : self .last_modified_date .isoformat (),
0 commit comments