예제 #1
0
def load_reviewers(filename):
    reviewers_by_date = defaultdict(set)
    with open(filename, 'rb') as f:
        for line in f:
            if line:
                review_data = json.loads(line)
            else:
                continue
            if 'comments' not in review_data:
                continue
            for review_comment in review_data['comments']:
                when = review_comment['timestamp']
                when = datetime.datetime.utcfromtimestamp(when).strftime(
                    '%Y-%m-%d')
                reviewer = review_comment['reviewer']
                if 'email' not in reviewer:
                    continue
                email = '<%s>' % reviewer['email']
                name_email = '%s %s' % (reviewer['name'], email)
                # name_email = name_email.decode('utf8')
                name_email = '%s %s' % (map_one_person(name_email), email)
                if name_email.lower() in excluded_authors:
                    continue
                reviewers_by_date[when].add(name_email)
    return reviewers_by_date
예제 #2
0
def load_reviewers(filename):
    reviewers_by_date = defaultdict(set)
    with open(filename, 'rb') as f:
        for line in f:
            if line:
                review_data = json.loads(line)
            else:
                continue
            if 'comments' not in review_data:
                continue
            for review_comment in review_data['comments']:
                when = review_comment['timestamp']
                when = datetime.datetime.utcfromtimestamp(when).strftime('%Y-%m-%d')
                reviewer = review_comment['reviewer']
                if 'email' not in reviewer:
                    continue
                email = '<%s>' % reviewer['email']
                name_email = '%s %s' % (reviewer['name'], email)
                # name_email = name_email.decode('utf8')
                name_email = '%s %s' % (map_one_person(name_email), email)
                if name_email.lower() in excluded_authors:
                    continue
                reviewers_by_date[when].add(name_email)
    return reviewers_by_date
예제 #3
0
        # (days, (rolling_avg_span, ...))
        (30, (180, 365)),
        (7, (30, 180)),
    ]
    actives = {x: [] for (x, _) in actives_windows}
    rolling_sets = {x: RollingSet(x) for (x, _) in actives_windows}
    actives_avg = {x: defaultdict(list) for (x, _) in actives_windows}

    for date in date_range(global_first_date, global_last_date):
        contribs = contribs_by_date.get(date, set())
        reviews = reviewers_by_date.get(date, set())
        mapped_contribs = set()
        for person in contribs:
            name, email = person.split('<', 1)
            email = '<' + email
            p = '%s %s' % (map_one_person(person), email)
            if p.lower() in excluded_authors:
                continue
            mapped_contribs.add(name)
        mapped_reviews = set()
        for person in reviews:
            name, email = person.split('<', 1)
            email = '<' + email
            p = '%s %s' % (map_one_person(person), email)
            if p.lower() in excluded_authors:
                continue
            mapped_reviews.add(name)
        people_by_date[date]['contribs'] = mapped_contribs
        people_by_date[date]['reviews'] = mapped_reviews
        unique_reviewer_set.update(mapped_reviews)
        date_obj = datetime.datetime.strptime(date, '%Y-%m-%d')
예제 #4
0
    return contribs_by_date, authors_by_count


def save_commits(data):
    with open(COMMITS_FILENAME, 'wb') as f:
        json.dump(data, f)


if __name__ == '__main__':
    people_by_date = collections.defaultdict(list)
    dates_by_person = collections.defaultdict(list)
    for line in sys.stdin.readlines():
        if not line.strip():
            continue
        name, email, timestamp = line.strip().split('|')
        person = ('%s %s' % (name, email)).decode('utf8')
        person = '%s %s' % (map_one_person(person), email)
        if person.lower() in excluded_authors:
            continue
        ts = dateutil.parser.parse(timestamp).strftime('%Y-%m-%d')
        people_by_date[ts].append(person)
        dates_by_person[person].append(ts)

    # fill in any missing days
    first_date = min(people_by_date.keys())
    for day in date_range(first_date, datetime.datetime.now()):
        if day not in people_by_date:
            people_by_date[day] = []

    save_commits((people_by_date, dates_by_person))