@@ -11,7 +11,7 @@ class ImpressionsMode(Enum):
11
11
class Manager (object ): # pylint:disable=too-few-public-methods
12
12
"""Impression manager."""
13
13
14
- def __init__ (self , strategy , telemetry_runtime_producer ):
14
+ def __init__ (self , strategy , none_strategy , telemetry_runtime_producer ):
15
15
"""
16
16
Construct a manger to track and forward impressions to the queue.
17
17
@@ -23,19 +23,33 @@ def __init__(self, strategy, telemetry_runtime_producer):
23
23
"""
24
24
25
25
self ._strategy = strategy
26
+ self ._none_strategy = none_strategy
26
27
self ._telemetry_runtime_producer = telemetry_runtime_producer
27
28
28
- def process_impressions (self , impressions ):
29
+ def process_impressions (self , impressions_decorated ):
29
30
"""
30
31
Process impressions.
31
32
32
33
Impressions are analyzed to see if they've been seen before and counted.
33
34
34
- :param impressions : List of impression objects with attributes
35
- :type impressions : list[tuple[splitio.models.impression.Impression , dict]]
35
+ :param impressions_decorated : List of impression objects with attributes
36
+ :type impressions_decorated : list[tuple[splitio.models.impression.ImpressionDecorated , dict]]
36
37
37
38
:return: processed and deduped impressions.
38
39
:rtype: tuple(list[tuple[splitio.models.impression.Impression, dict]], list(int))
39
40
"""
40
- for_log , for_listener , for_counter , for_unique_keys_tracker = self ._strategy .process_impressions (impressions )
41
- return for_log , len (impressions ) - len (for_log ), for_listener , for_counter , for_unique_keys_tracker
41
+ for_listener_all = []
42
+ for_log_all = []
43
+ for_counter_all = []
44
+ for_unique_keys_tracker_all = []
45
+ for impression_decorated , att in impressions_decorated :
46
+ if not impression_decorated .track :
47
+ for_log , for_listener , for_counter , for_unique_keys_tracker = self ._none_strategy .process_impressions ([(impression_decorated .Impression , att )])
48
+ else :
49
+ for_log , for_listener , for_counter , for_unique_keys_tracker = self ._strategy .process_impressions ([(impression_decorated .Impression , att )])
50
+ for_listener_all .extend (for_listener )
51
+ for_log_all .extend (for_log )
52
+ for_counter_all .extend (for_counter )
53
+ for_unique_keys_tracker_all .extend (for_unique_keys_tracker )
54
+
55
+ return for_log_all , len (impressions_decorated ) - len (for_log_all ), for_listener_all , for_counter_all , for_unique_keys_tracker_all
0 commit comments