예제 #1
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.task_key = 'out-step0-{}{:%Y%m%d}'.format(self.period, self.date_target)
     self.bq_script = None
     self.pre_tasks = []
     self.delete_tables = []
     
     if (self.period == 'W'):
         self.date_start = self.date_target
         self.date_end = jbtools.add_days(self.date_target, 6)
         self.date_start_prev = jbtools.add_days(self.date_target, -7)
     else:
         self.date_start = jbtools.get_date_month_start(self.date_target)
         self.date_end = jbtools.get_date_month_end(self.date_target)
         self.date_start_prev = jbtools.get_date_prev_month_start(self.date_target)
예제 #2
0
    def requires(self):
        pre_tasks = {}

        print('requires....')
        logging.info('requires....')
        if self.period == 'W':    
            date_current = self.date_start
        else:
            date_current = jbtools.get_date_month_start(self.date_start)
        
        
        while (date_current <= self.date_end):
            date_prev = None
            if self.period == 'W':
                date_prev = util.add_days(date_current, -7)
            else:
                date_prev = jbtools.get_date_prev_month_start(date_current)
            
            if self.period == 'W' and date_current > util.add_days(self.date_start, 7):
                rpt_task = NesStep41Task(date_target=date_current, project_id='1049530906192', period=self.period)
            elif self.period == 'M' and date_current > jbtools.get_date_month_start(self.date_start):
                rpt_task = NesStep41Task(date_target=date_current, project_id='1049530906192', period=self.period)
            else:
                rpt_task = NesStep09Task(date_target=date_current, project_id='1049530906192', period=self.period)
            
            rpt_key = self.get_report_key(date_current, self.period)
            pre_tasks[rpt_key] = rpt_task
            
            rpt_key_prev = self.get_report_key(date_prev, self.period)
            if rpt_key_prev in pre_tasks:
                rpt_task.pre_tasks.append(pre_tasks[rpt_key_prev])
            
            if self.period == 'W':    
                date_current = util.add_days(date_current, 1)
            else:
                date_current = jbtools.get_date_next_month_start(date_current)
        return pre_tasks