@@ -27,7 +27,8 @@ def create_task(self):
27
27
result = []
28
28
for domain_info in self .list_domains ():
29
29
stp = self ._create_job_request (domain_info ["domain_id" ], current_hour )
30
- result .append (stp )
30
+ if stp is not None :
31
+ result .append (stp )
31
32
return result
32
33
33
34
def list_domains (self ):
@@ -58,31 +59,35 @@ def _list_schedule(self, domain_id: str, current_hour: int):
58
59
return schedules
59
60
60
61
def _create_job_request (self , domain_id : str , current_hour : int ):
61
- _LOGGER .debug (f"[_create_job_request] domain: { domain_id } " )
62
62
schedules = self ._list_schedule (domain_id , current_hour )
63
- schedule_jobs = []
64
- for schedule in schedules :
65
- job = {
66
- "locator" : "SERVICE" ,
67
- "name" : "HistoryService" ,
68
- "metadata" : {
69
- "token" : self ._token ,
70
- },
71
- "method" : "create" ,
72
- "params" : {
63
+ schedule_count = len (schedules )
64
+ if schedule_count > 0 :
65
+ _LOGGER .debug (f"[_create_job_request] { domain_id } : { len (schedules )} " )
66
+
67
+ schedule_jobs = []
68
+ for schedule in schedules :
69
+ job = {
70
+ "locator" : "SERVICE" ,
71
+ "name" : "HistoryService" ,
72
+ "metadata" : {
73
+ "token" : self ._token ,
74
+ },
75
+ "method" : "create" ,
73
76
"params" : {
74
- "schedule_id" : schedule .schedule_id ,
75
- "domain_id" : domain_id ,
76
- }
77
- },
78
- }
79
- schedule_jobs .append (job )
77
+ "params" : {
78
+ "schedule_id" : schedule .schedule_id ,
79
+ "domain_id" : domain_id ,
80
+ }
81
+ },
82
+ }
83
+ schedule_jobs .append (job )
80
84
81
- stp = {
82
- "name" : "statistics_hourly_schedule" ,
83
- "version" : "v1" ,
84
- "executionEngine" : "BaseWorker" ,
85
- "stages" : schedule_jobs ,
86
- }
87
- _LOGGER .debug (f"[_create_job_request] tasks: { stp } " )
88
- return stp
85
+ stp = {
86
+ "name" : "statistics_hourly_schedule" ,
87
+ "version" : "v1" ,
88
+ "executionEngine" : "BaseWorker" ,
89
+ "stages" : schedule_jobs ,
90
+ }
91
+ return stp
92
+ else :
93
+ return None
0 commit comments