Skip to content

Commit

Permalink
Parallelize repository commit queries
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwager committed Oct 1, 2016
1 parent af13dc5 commit 194f457
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions lib/gitem/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import argparse
import functools
import multiprocessing

from gitem import api
from gitem import analytics
Expand Down Expand Up @@ -125,6 +126,7 @@ def repository(ghapi, *args, **kwargs):
def user(ghapi, *args, **kwargs):
username = kwargs['name']
verbose = kwargs['verbose']
processes = kwargs['processes']

user_info = analytics.get_user_information(
ghapi,
Expand Down Expand Up @@ -172,15 +174,15 @@ def user(ghapi, *args, **kwargs):
for repository in user_repositories
]

user_repository_emails = [
analytics.get_repository_commit_emails(
ghapi,
username,
repository,
author=username
)
for repository in user_repository_names
]
pool = multiprocessing.Pool(processes=processes)
partial_email_fn = functools.partial(
analytics.get_repository_commit_emails,
ghapi,
username,
author=username
)

user_repository_emails = pool.map(partial_email_fn, user_repository_names)

user_emails = functools.reduce(set.union, user_repository_emails, set())

Expand All @@ -207,6 +209,14 @@ def parse_args():
action='store_true',
help='verbose output'
)
p.add_argument(
'-p',
'--processes',
action='store',
type=int,
default=1,
help='number of processes (for applicable commands)'
)

subparsers = p.add_subparsers(dest='command')

Expand Down

0 comments on commit 194f457

Please sign in to comment.