예제 #1
0
 def get_overdue_tickets(self, max_time):
     open_overdue_tickets = []
     open_tickets = self.df[self.df['ticket_state_name'] == 'open']
     for idx, row in open_tickets.iterrows():
         delta = RegularWorkingTime().compute_working_time(
             row['tcreatetime'], datetime.now())
         if delta >= max_time:
             open_overdue_tickets.append(row)
     return pd.DataFrame(open_overdue_tickets)
예제 #2
0
 def get_new_tickets_hour(self):
     new_tickets_hour = []
     new_tickets = self.df[self.df['ticket_state_name'] == 'new']
     for idx, row in new_tickets.iterrows():
         delta = RegularWorkingTime().compute_working_time(
             row['tcreatetime'], datetime.now())
         if delta > 1:
             new_tickets_hour.append(row)
     return pd.DataFrame(new_tickets_hour)
예제 #3
0
 def get_risk_tickets(self, max_time, threshold=1):
     open_risk_tickets = []
     open_tickets = self.df[self.df['ticket_state_name'] == 'open']
     for idx, row in open_tickets.iterrows():
         delta = RegularWorkingTime().compute_working_time(
             row['tcreatetime'], datetime.now())
         if max_time - threshold < delta < max_time:
             open_risk_tickets.append(row)
     return pd.DataFrame(open_risk_tickets)
예제 #4
0
def close_time_calculation(df):
    auto_close = []
    forced_close = []
    for i in range(len(df)):
        if df['auto_close'][i] != '\\N' and not pd.isnull(df['auto_close'][i]):
            result = RegularWorkingTime().compute_working_time(
                df['tcreatetime'][i], df['auto_close'][i], False)
        else:
            result = None
        auto_close.append(result)
        if df['closed'][i] != '\\N' and not pd.isnull(df['closed'][i]):
            result = RegularWorkingTime().compute_working_time(
                df['tcreatetime'][i], df['closed'][i], False)
        else:
            result = None
        forced_close.append(result)
    df['auto_closed'] = auto_close
    df['forced_close'] = forced_close
예제 #5
0
 def get_new_tickets_after_first_line(self, max_time=1):
     tickets = []
     new_tickets = self.df[self.df['ticket_state_name'] == 'new']
     for idx, row in new_tickets.iterrows():
         delta = RegularWorkingTime().compute_working_time(
             row['tcreatetime'], datetime.now())
         if delta > max_time and not pd.isnull(row['in_working_first'])\
            and not pd.isnull(row['first_line_emergence_time'])\
            and row['first_line_emergence_time'] != '':
             tickets.append(row)
     return pd.DataFrame(tickets)
예제 #6
0
 def compute_contractor_time(task):
     time = 0
     _start = None
     _end = None
     for idx, row in task.iterrows():
         if row[1] in WAITING_STATES:
             _start = row[3]
         elif _start:
             _end = row[3]
             diff = RegularWorkingTime().compute_working_time(
                 _start.strftime("%Y-%m-%d %H:%M"),
                 _end.strftime("%Y-%m-%d %H:%M"))
             time += diff
             _start, _end = None, None
     return time
예제 #7
0
def lines_working_time(df,
                       name_emergence_time,
                       name_lock_time,
                       full_time=False):
    emergence_time = df[name_emergence_time]
    lock_time = df[name_lock_time]
    in_working = []
    for i in range(len(df)):
        result = None
        # if lock_time[i] != '\\N':
        try:
            if full_time:
                result = FirstLineWorkingTime().compute_working_time(
                    emergence_time[i], lock_time[i], False)
            else:
                result = RegularWorkingTime().compute_working_time(
                    emergence_time[i], lock_time[i], False)
        except:
            pass
        # else:
        # result = ''
        in_working.append(result)
    return in_working
예제 #8
0
 def test_case2(self):
     start = '2018-07-01 14:50'
     end = '2018-07-02 08:10'
     res = RegularWorkingTime().compute_working_time(start, end, False)
     self.assertEqual(res, 0)