Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Nov 8, 2023
1 parent 67cdb4b commit b7e7f36
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def _not_found(self, url: str, tag: str) -> Issue:

def _get_user_issues2( # pylint: disable=too-many-arguments
self,
username: str = "",
assigned: bool = False,
created: bool = False,
involved: bool = True,
Expand All @@ -200,17 +199,16 @@ def _get_user_issues2( # pylint: disable=too-many-arguments
futures = []
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
if assigned:
futures.append(executor.submit(self.get_assigned, username, **kwargs))
futures.append(executor.submit(self.get_assigned, **kwargs))
if created:
futures.append(executor.submit(self.get_created, username, **kwargs))
futures.append(executor.submit(self.get_created, **kwargs))
for future in concurrent.futures.as_completed(futures):
issues.extend(future.result())

return list(set(issues))

def _get_user_issues4( # pylint: disable=too-many-arguments
self,
username: str = "",
assigned: bool = False,
created: bool = False,
involved: bool = True,
Expand All @@ -226,27 +224,15 @@ def _get_user_issues4( # pylint: disable=too-many-arguments
futures = []
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
if assigned:
futures.append(
executor.submit(
self.get_assigned, username, pull_requests=False, **kwargs
for pr in (False, True):
futures.append(
executor.submit(self.get_assigned, pull_requests=pr, **kwargs)
)
)
futures.append(
executor.submit(
self.get_assigned, username, pull_requests=True, **kwargs
)
)
if created:
futures.append(
executor.submit(
self.get_created, username, pull_requests=False, **kwargs
)
)
futures.append(
executor.submit(
self.get_created, username, pull_requests=True, **kwargs
for pr in (False, True):
futures.append(
executor.submit(self.get_created, pull_requests=pr, **kwargs)
)
)
for future in concurrent.futures.as_completed(futures):
issues.extend(future.result())

Expand Down

0 comments on commit b7e7f36

Please sign in to comment.