def writeIntervalsBreaks_Files(commit_table):
    # Calcola days between commits, if commits are in adjacent days count 1
    inactivity_intervals_data = []
    break_dates = []
    for index, u in commit_table.iterrows():
        row = [u[0]]  #User_id
        current_break_dates = [u[0]]  #User_id
        commit_dates = []
        for i in range(1, len(u)):
            if (u[i] > 0):
                commit_dates.append(commit_table.columns[i])
        for i in range(0, len(commit_dates) - 1):
            period = util.days_between(commit_dates[i], commit_dates[i + 1])
            if (period > 1):
                row.append(period)
                current_break_dates.append(commit_dates[i] + "/" +
                                           commit_dates[i + 1])
        #print('Last User Done: ', row[0])
        inactivity_intervals_data.append(row)
        break_dates.append(current_break_dates)
        user_lifespan = util.days_between(
            commit_dates[0], commit_dates[len(commit_dates) - 1]) + 1
        commit_frequency = len(commit_dates) / user_lifespan
        row.append(user_lifespan)
        row.append(commit_frequency)
    print('Inactivity Computation Done: ', project_name)

    with open(super_path + '/' + project_name +
              '/inactivity_interval_list.csv',
              'w',
              newline='') as outcsv:
        #configure writer to write standard csv file
        writer = csv.writer(outcsv,
                            quoting=csv.QUOTE_NONE,
                            quotechar='"',
                            escapechar='\\')
        for r in inactivity_intervals_data:
            #Write item to outcsv
            writer.writerow(r)

    with open(super_path + '/' + project_name + '/break_dates_list.csv',
              'w',
              newline='') as outcsv:
        #configure writer to write standard csv file
        writer = csv.writer(outcsv,
                            quoting=csv.QUOTE_NONE,
                            quotechar='"',
                            escapechar='\\')
        for r in break_dates:
            #Write item to outcsv
            writer.writerow(r)
    logging.info('Project: ' + project_name + ' DONE')
Ejemplo n.º 2
0
active_devs_sleeping_intervals_df = []
active_devs_hibernation_intervals_df = []
active_devs_dead_intervals_df = []

active_users = []
for index, row in active_users_df.iterrows():
    user_id = row['durations'][0]
    active_users.append(user_id)
ae.get_repo_activities(g, repo, project_name, project_start_dt, active_users)

n = 0
for index, row in active_users_df.iterrows():
    user_id = row['durations'][0]

    last_commit_day = util.getLastCommitDay(commit_table, user_id)
    last_break_length = util.days_between(last_commit_day, project_end)
    last_break_interval = last_commit_day + '/' + project_end

    row['durations'] = pandas.to_numeric(row['durations'][1:-2], 'raise',
                                         'integer').tolist()
    row['durations'].append(last_break_length)
    row['datelimits'] = row['datelimits'][1:]
    row['datelimits'].append(last_break_interval)

    path = (super_path + '/' + project_name + '/Activities_Plots/' + user_id)
    os.makedirs(path, exist_ok=True)

    if 'actions_table.csv' in os.listdir(path):
        user_actions = pandas.read_csv(path + '/actions_table.csv', sep=';')
    else:
        user_actions = ae.get_activities(g, repo, project_name,