@@ -73,11 +73,10 @@ def get_tasks(
73
73
}
74
74
}
75
75
)
76
- changed .append ({"start" : start_month })
77
- synced_accounts .extend (
78
- {"account_id" : tenant_id }
79
- for tenant_id in divided_customer_tenant_info
76
+ synced_accounts = self ._extend_synced_accounts (
77
+ synced_accounts , divided_customer_tenant_info
80
78
)
79
+ changed .append ({"start" : start_month })
81
80
if first_sync_tenants :
82
81
first_sync_start_month = self ._get_start_month (start = None )
83
82
tasks .append (
@@ -91,9 +90,15 @@ def get_tasks(
91
90
}
92
91
}
93
92
)
94
- changed .append ({"start" : first_sync_start_month })
95
- synced_accounts .extend (
96
- {"account_id" : tenant_id } for tenant_id in first_sync_tenants
93
+ for tenant_id in first_sync_tenants :
94
+ changed .append (
95
+ {
96
+ "start" : first_sync_start_month ,
97
+ "filter" : {"additional_info.Tenant Id" : tenant_id },
98
+ }
99
+ )
100
+ synced_accounts = self ._extend_synced_accounts (
101
+ synced_accounts , first_sync_tenants
97
102
)
98
103
else :
99
104
tasks = [
@@ -167,27 +172,34 @@ def _get_customer_tenants(
167
172
if len (customer_tenants ) == 0 :
168
173
raise ERROR_EMPTY_CUSTOMER_TENANTS (customer_tenants = customer_tenants )
169
174
170
- if linked_accounts :
171
- linked_accounts_map = {
172
- linked_account ["account_id" ]: linked_account
173
- for linked_account in linked_accounts
174
- }
175
-
176
- for customer_tenant_id in customer_tenants :
177
- if linked_account_info := linked_accounts_map .get (customer_tenant_id ):
178
- if not linked_account_info .get ("is_sync" ):
179
- first_sync_customer_tenants .append (
180
- linked_account_info .get ("account_id" )
181
- )
182
- customer_tenants .remove (customer_tenant_id )
183
- else :
184
- _LOGGER .debug (
185
- f"[_get_customer_tenants] Customer tenant is not linked: { linked_account_info } "
186
- )
187
- customer_tenants .remove (customer_tenant_id )
175
+ # if linked_accounts:
176
+ # linked_accounts_map = {
177
+ # linked_account["account_id"]: linked_account
178
+ # for linked_account in linked_accounts
179
+ # }
180
+ #
181
+ # for customer_tenant_id in customer_tenants:
182
+ # if linked_account_info := linked_accounts_map.get(customer_tenant_id):
183
+ # if not linked_account_info.get("is_sync"):
184
+ # first_sync_customer_tenants.append(
185
+ # linked_account_info.get("account_id")
186
+ # )
187
+ # customer_tenants.remove(customer_tenant_id)
188
+ # else:
189
+ # _LOGGER.debug(
190
+ # f"[_get_customer_tenants] Customer tenant is not linked: {linked_account_info}"
191
+ # )
192
+ # customer_tenants.remove(customer_tenant_id)
188
193
189
194
return customer_tenants , first_sync_customer_tenants
190
195
196
+ @staticmethod
197
+ def _extend_synced_accounts (synced_accounts : list , customer_tenants : list ) -> list :
198
+ synced_accounts .extend (
199
+ {"account_id" : tenant_id } for tenant_id in customer_tenants
200
+ )
201
+ return synced_accounts
202
+
191
203
@staticmethod
192
204
def _get_divided_customer_tenants (customer_tenants_info : list ) -> list :
193
205
tenant_size = math .ceil (len (customer_tenants_info ) / _TASK_LIST_SIZE )
0 commit comments