@@ -47,7 +47,7 @@ def run(self, params={}, state={}, custom_config={}): # pylint: disable=unused-
47
47
run_condition = self .detect_run_condition (state .get (QUERY_CONFIG , {}), now_date )
48
48
self .logger .info (f"TASK: Run state is { run_condition } " )
49
49
state = self .update_state (state )
50
- page_size , thead_count = self .apply_custom_config (state , custom_config )
50
+ page_size , thead_count = self .apply_custom_config (state , run_condition , custom_config )
51
51
max_run_lookback_date = self .get_max_lookback_date (now_date , run_condition , bool (custom_config ))
52
52
query_config = self .prepare_query_params (state .get (QUERY_CONFIG , {}), max_run_lookback_date , now_date )
53
53
logs , query_config = self .get_all_logs (run_condition , query_config , page_size , thead_count )
@@ -114,20 +114,24 @@ def get_max_lookback_date(self, now_date: datetime, run_condition: str, custom_c
114
114
max_run_lookback_date = now_date - timedelta (days = max_run_lookback_days )
115
115
return max_run_lookback_date
116
116
117
- def apply_custom_config (self , state : Dict , custom_config : Dict = {}) -> Tuple [int , int ]:
117
+ def apply_custom_config (self , state : Dict , run_type : str , custom_config : Dict = {}) -> Tuple [int , int ]:
118
118
"""
119
119
Apply custom configuration for lookback, query date applies to start and end time of query
120
120
:param current_query_config:
121
+ :param run_type:
121
122
:param custom_config:
122
- :return:
123
+ :return: Page size and thread count
123
124
"""
125
+ custom_query_config = {}
124
126
if custom_config :
125
127
self .logger .info ("TASK: Custom config detected" )
126
- if not state :
128
+ custom_query_config = custom_config .get ("query_config" , {})
129
+ if run_type == INITIAL_RUN :
127
130
current_query_config = state .get (QUERY_CONFIG )
128
- for log_type , query_date_string in custom_config .items ():
129
- self .logger .info (f"TASK: Supplied lookback date of { query_date_string } for log type { log_type } " )
130
- current_query_config [log_type ] = {QUERY_DATE : query_date_string }
131
+ for log_type , log_query_config in custom_query_config .items ():
132
+ log_query_date = log_query_config .get ("query_date" , None )
133
+ self .logger .info (f"TASK: Supplied lookback date of { log_query_date } for log type { log_type } " )
134
+ current_query_config [log_type ] = {QUERY_DATE : log_query_date }
131
135
page_size = max (1 , min (custom_config .get (PAGE_SIZE , DEFAULT_PAGE_SIZE ), DEFAULT_PAGE_SIZE ))
132
136
thread_count = max (1 , custom_config .get (THREAD_COUNT , DEFAULT_THREAD_COUNT ))
133
137
return page_size , thread_count
0 commit comments